home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / litecom6.arc / LCDOC.EXE / LC6.DOC next >
Text File  |  1991-08-25  |  149KB  |  4,029 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.           OVERVIEW .                                         ..                      .                       .                        .                         .                          .                           .                            .                                                           .                               .                                .                                 ..                                                                     .                                    .                                     .                                      .                                       .                                        .                                         .                                          .                                           .                                            .                                             .                                              .                                               .                                                .                                                 ..                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                            .                                                             .                                                              .                                                               .                                                                .                                                                 .                                                                  .                                                                   .                                                                    .                                                                                                                                           .                                                                       ..                                                                        .                                                                         .                                                                          .                                                                            1
  7.             INTRODUCTION                             .                            .                             .                              .                               .                                .                                 .                                  .                                   .                                    .                                     .                                      ..                                       .                                        .                                         .                                          .                                           .                                            .                                             .                                              .                                               .                                                .                                                 .                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                            .                                                             .                                                              .                                                               .                                                                .                                                                 .                                                                  .                                                                   .                                                                    .                                                                     .                                                                      .                                                                       .                                                                        .                                                                         .                                                                          .                                                                            1
  8.  
  9.             What is Shareware                                  .                                 .                                  .                                   .                                    .                                     .                                      .                                       .                                        .                                         .                                          .                                           .                                            .                                             .                                              .                                               .                                                .                                                 .                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                            .                                                             .                                                              .                                                               .                                                                .                                                                 .                                                                  .                                                                   .                                                                    .                                                                     .                                                                      .                                                                       ..                                                                        .                                                                         .                                                                          .                                                                            1
  10.             LICENSE, WARRANTY AND REGISTRATION  .                                                 .                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                            .                                                             .                                                              .                                                               .                                                                .                                                                 .                                                                  .                                                                   .                                                                    .                                                                     .                                                                      .                                                                       .                                                                        .                                                                         .                                                                          .                                                                            2
  11.                LICENSE .                        .                         .                          .                           .                            .                             .                              .                               .                                .                                 .                                  .                                   .                                    .                                     .                                      .                                       .                                        .                                         .                                          .                                           .                                            .                                             .                                              .                                               .                                                .                                                 .                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                            .                                                             .                                                              .                                                               .                                                                .                                                                 .                                                                  .                                                                   .                                                                    .                                                                     .                                                                      .                                                                       .                                                                        .                                                                         .                                                                          .                                                                            2
  12.  
  13.                WARRANTY                          .                          .                           .                            .                             .                              .                               .                                .                                 .                                  .                                   .                                    .                                     .                                      .                                       .                                        .                                         .                                          .                                           .                                            .                                             .                                              .                                               .                                                .                                                 .                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                            .                                                             .                                                              .                                                               .                                                                .                                                                 .                                                                  .                                                                   .                                                                    ..                                                                     .                                                                      .                                                                       .                                                                        .                                                                         .                                                                          .                                                                            2
  14.                REGISTRATION .                             .                              .                               .                                .                                 .                                  .                                   .                                                                         ..                                      .                                       .                                        .                                         .                                          .                                           .                                                                                         ..                                              .                                               .                                                                                                 ..                                                  .                                                   .                                                                                                         ..                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                                                                                         ..                                                              .                                                               .                                                                                                                                 ..                                                                  .                                                                   .                                                                                                                                         ..                                                                      .                                                                       .                                                                        .                                                                         .                                                                          .                                                                            2
  15.                IS REGISTRATION WORTHWHILE? .                                            .                                             .                                              .                                               .                                                .                                                 .                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                           .                                                            .                                                             .                                                                                                                             ..                                                                .                                                                 .                                                                                                                                     ..                                                                    .                                                                     .                                                                                                                                             ..                                                                        .                                                                                                                                                   ..                                                                            2
  16.  
  17.           Serial Port Fundamentals .                                                                         ..                                      .                                       .                                        .                                         .                                          .                                           .                                                                                         ..                                                                                             ..                                                                                                 ..                                                  .                                                   .                                                    .                                                     .                                                      .                                                       .                                                        .                                                         .                                                          .                                                                                                                       ..                                                             .                                                              .                                                                                                                               .                                                                 ..                                                                  .                                                                                                                                       .                                                                     ..                                                                                                                                             ..                                                                        .                                                                                                                                                   .                                                                           . 3
  18.             The 8250 UART family  .                                                                       ..                                     .                                                                             ..                                                                                 ..                                                                                     ..                                                                                         ..                                              .                                               .                                                                                                 ..                                                                                                     .                                                    .                                                     ..                                                                                                             ..                                                                                                                 ..                                                                                                                     ..                                                                                                                         ..                                                              .                                                               .                                                                .                                                                 .                                                                                                                                     ..                                                                                                                                         ..                                                                      .                                                                                                                                               ..                                                                         .                                                                                                                                                     . 3
  19.                Purpose of the port .                                    .                                     .                                                                             ..                                        .                                         .                                          .                                           .                                            .                                                                                           ..                                               .                                                                                                 ..                                                                                                     ..                                                    .                                                     .                                                      .                                                                                                               ..                                                                                                                   ..                                                           .                                                            .                                                             .                                                              .                                                               .                                                                .                                                                                                                                   ..                                                                   .                                                                    .                                                                     .                                                                      .                                                                       .                                                                                                                                                 ..                                                                          .                                                                            3
  20.  
  21.             INTERNAL PORT DETAILS  .                                    .                                                                           ..                                       .                                        .                                         .                                                                                     ..                                                                                         .                                              .                                               ..                                                                                                 ..                                                  .                                                   .                                                                                                         .                                                      .                                                       ..                                                                                                                 ..                                                          .                                                                                                                       .                                                             .                                                              .                                                               ..                                                                                                                                 .                                                                  .                                                                   ..                                                                                                                                         .                                                                      ..                                                                                                                                               ..                                                                         .                                                                                                                                                     . 3
  22.                The Interrupt Connection                                          .                                          .                                           ..                                            .                                                                                           ..                                               .                                                .                                                                                                   .                                                   ..                                                                                                         .                                                      .                                                       .                                                        ..                                                                                                                   .                                                           .                                                            .                                                             ..                                                              .                                                               .                                                                .                                                                                                                                   ..                                                                                                                                       .                                                                     .                                                                      .                                                                       ..                                                                                                                                                 ..                                                                          .                                                                            4
  23.  
  24.                THE PORT REGISTERS                  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.                                      LiteComm
  36.  
  37.                               Communications ToolBox
  38.  
  39.                               Copyright 1987 - 1991 
  40.                            Information Technology, Ltd.
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.                              Information Technology
  65.                                   5 Park Blvd.
  66.                                Lincoln, RI 02865
  67.                                  (401) 724-2730
  68.  
  69.  
  70.  
  71.  
  72.                                       OVERVIEW
  73.  
  74.  
  75.  
  76.        INTRODUCTION
  77.  
  78.                                 TM
  79.             The LiteComm ToolBox   is a set of powerful routines designed to
  80.             provide easy access to the full capabilities of the PC's asynch-
  81.             ronous communications ports. The LiteComm ToolBox provides
  82.             interrupt-driven, buffered communications support on COM1 through
  83.             COM4 simultaneously. Now you can quickly incorporate sophis-
  84.             ticated communications support in your applications without hav-
  85.             ing in-depth knowledge of how the hardware functions.
  86.  
  87.             LiteComm is the result of meeting a need for communications in
  88.             CAD/CAM applications created for a client company. Each version
  89.             of the LiteComm ToolBox depends upon its respective host compil-
  90.             er.
  91.  
  92.  
  93.             The 'Lite' in LiteComm refers to the high granularity of the
  94.             product. LiteComm, in simple applications, adds about 5K bytes of
  95.             overhead. Yet it provides a highly reliable base on which to
  96.             build.
  97.  
  98.             As you use LiteComm, you will find yourself in good company. Li-
  99.             teComm is currently in use at ATT, IBM, NASA, and the Associated
  100.             Press, to name a few of our users. In addition, LiteComm has been
  101.             featured in at least one book, Straight Talk by Charles Bowen and
  102.             Stewart Schneider. Finally, the Turbo Pascal version of LiteComm
  103.             is the basis for the Async Professional package from Turbopower
  104.             Software.
  105.  
  106.  
  107.        What is Shareware
  108.             Shareware is a "try before you buy" means of software distribu-
  109.             tion. If you find a shareware product useful, pay the registra-
  110.             tion fee, and let the authors know that you support their
  111.             efforts.
  112.  
  113.  
  114.             Information Technology is a member of the Association of Share-
  115.             ware Professionals (ASP).  ASP wants to make sure that the
  116.             shareware principle works for you.  If you are unable to resolve
  117.             a shareware-related problem with an ASP member by contacting the
  118.             member directly, ASP may be able to help.  The ASP Ombudsman can
  119.             help you resolve a dispute or problem with an ASP member, but
  120.             does not provide technical support for members' products.  Please
  121.             write to the ASP Ombudsman at P.O.  Box 5786, Bellevue, WA 98006
  122.             or send a Compuserve message via easyplex to ASP Ombudsman
  123.             70007,3536. 
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                             1
  130.  
  131.  
  132.  
  133.  
  134.        LICENSE, WARRANTY AND REGISTRATION
  135.             LICENSE
  136.             Information regarding the LiteComm license will be found in the
  137.             file LICENSE.DOC, on the distribution diskette. Please read this
  138.             information. By your use of LiteComm, we assume that you agree to
  139.             the terms and conditions of the license agreement.
  140.  
  141.  
  142.             If you are interested in a site license for LiteComm, please see
  143.             the file SITELICE.DOC on the distribution disk.
  144.  
  145.             WARRANTY
  146.  
  147.             The LiteComm warranty is in the distributed file WARRANTY.DOC. Be            sure you read the  warranty before using LiteComm.
  148.  
  149.  
  150.             REGISTRATION
  151.             Registration information and an order form are in the file
  152.             REGISTER.DOC.
  153.  
  154.  
  155.             IS REGISTRATION WORTHWHILE?
  156.             LiteComm is a package undergoing continuing development.  We are
  157.             constantly reviewing the product to make it smaller, faster, more
  158.             reliable, and easier to use.  Since its introduction in mid 1987,
  159.             we have made significant changes to the LiteComm kernel, the
  160.             heart of the ToolBox, to improve efficiency and reliability.  We
  161.             have also delivered to registered users protocol engines, LXM -
  162.             the Xmodem engine, which supports Xmodem and Xmodem-1K; and LWXM
  163.             -  the Windowed Xmodem engine.  We also provide a version of the
  164.             Compuserve QUICKB protocol, specially adapted for use with the
  165.             LiteComm ToolBox.
  166.  
  167.  
  168.             We are also reviewing other protocol engine implementations. In
  169.             this release of LiteComm, for example, we have added support for
  170.             True YModem and ZModem. The small model library, as enhanced will
  171.             always be offered as a shareware product.
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.                                             2
  192.  
  193.  
  194.  
  195.  
  196.                               Serial Port Fundamentals
  197.  
  198.  
  199.  
  200.        The 8250 UART family
  201.  
  202.             This portion of the manual provides you with some details about            the working of the 8250 (and related) UART'S, the basic component
  203.             of your system's serial port.  Some close compatibles use en-
  204.             hanced versions of this chip, such as the 16450 and 16550.
  205.             LiteComm works successfully with such devices.  If you have
  206.             questions about the type of serial port you are using, refer to
  207.             the manufacturer's documentation.  If your serial port does not
  208.             use an 8250 or similar chip, LiteComm will not function.
  209.  
  210.  
  211.             Purpose of the port
  212.             The serial port converts information from the form in which it is
  213.             used within your system, to a form that can be easily used out-
  214.             side your system.  Modern computers, by design, are parallel in
  215.             nature.  By this we mean that information travels through the
  216.             computer's circuitry as whole units or as multiples of whole
  217.             units. In the IBM PC and related systems, information travels as
  218.             bytes (8 bits at a time), as words (16 bits at a time), or, on
  219.             80386 and 80486 based systems, as double words (32 bits at a
  220.             time).
  221.  
  222.  
  223.             Within the computer, such arrangements are convenient and fast.
  224.             When the computer must transfer information to an external de-
  225.             vice, data path width is a problem.  To provide a parallel path
  226.             between the computer and external devices, there would have to be
  227.             enough data lines or circuits between the two to satisfy the data
  228.             path.  For most modern computer systems, this would mean a mini-
  229.             mum of 8 data lines, not counting any additional control
  230.             information that also might be necessary.  For certain newer
  231.             systems, the requirement might be for as many as 32 data lines.
  232.             In effect, it might be necessary to have several different ver-
  233.             sions of a device, dependent upon the data path width of the
  234.             computer.
  235.  
  236.             The purpose of a serial port is to convert the information from
  237.             its internal, parallel form, to a more common, external form and
  238.             back.  By using such an approach, we simplify the interconnection
  239.             of devices, reducing information to its lowest common denomina-
  240.             tor, the bit. It allows us to transfer information 1 bit at a
  241.             time, using a single data path, between devices. The real beauty
  242.             of this approach is that, by agreeing on how this external form
  243.             appears, each device can hide the details of how it works, and
  244.             still do the required task.
  245.  
  246.  
  247.        INTERNAL PORT DETAILS
  248.             In this section we discuss the fundamental working of serial
  249.             ports on the IBM PC and close compatible systems.  It is not es-
  250.             sential that you understand this material thoroughly to be
  251.             successful with LiteComm. Still, it may help to answer some more
  252.  
  253.                                             3
  254.  
  255.  
  256.  
  257.  
  258.             important questions that may arise as you proceed with your de-
  259.             velopment.
  260.  
  261.             The Interrupt Connection
  262.             The PC is an interrupt driven system. This is a sophisticated way
  263.             of saying that the PC can pay attention to several internal de-
  264.             vices. It doesn't have to check on, or poll, them periodically.
  265.  
  266.  
  267.             The method by which 80x86 family interrupts work is elegant in
  268.             its simplicity.  When a device needs the attention of the system,
  269.             its asserts a control signal and identifies itself with a number
  270.             ranging from 0 to 255. On the basic PC, the numbers used range
  271.             from 8 through 15 decimal.  PC components translate the
  272.             identification to a memory location by multiplying the identifi-
  273.             cation by 4. The system then simulates a special form of a call
  274.             to the routine whose address is at that memory location.  Since
  275.             it is impossible to predict when a device will require attention,
  276.             the system uses the far address of the routine, both segment and
  277.             offset, therefore the 4.
  278.  
  279.             Once called, this routine, called the Interrupt Service Routine
  280.             or ISR, has a duty to save the state of the system when the in-
  281.             terrupt occurred. It must take care of the interrupt as quickly
  282.             as possible, and return control to the interrupted process.  It
  283.             also must be aware that, while it is doing its work, other, more
  284.             important devices may require attention, too.
  285.  
  286.  
  287.             One device that requires constant attention is the system clock
  288.             that ticks roughly 18 times per second.  In part, the PC makes
  289.             provision for this by prioritizing the interrupt scheme.  The ISR
  290.             must allow for this by reenabling the interrupt control system as
  291.             rapidly as it is practical to do so.  The PC's interrupt struc-
  292.             ture, if left undisturbed, will prevent interrupts of the same or
  293.             lower priority from occurring. To help you organize your
  294.             thoughts, the standard identifications for the first two serial
  295.             ports on the system are 12 (0C) and 11 (0B) for ports 1 and 2
  296.             respectively.
  297.  
  298.             However, the intrreupt structure of the PC is far from perfect.
  299.             Systems that use the original ISA buss have a shortcoming. Only
  300.             one device is allowed to occupy an interrupt vector or location
  301.             at a time. This is in contrast to systems that employ either the
  302.             micro-channel buss or the EISA buss. In these latter two buss
  303.             designs, multiple devices may occupy a single intterupt location.
  304.  
  305.  
  306.             As you can see, dealing with the PC's interrupt structure is not
  307.             for the faint of heart.  It requires a significant amount of
  308.             knowledge, and close attention to detail.  LiteComm takes care of
  309.             these details for you.  You are free to focus on your applica-
  310.             tion, treating the serial port in much the same way that you
  311.             would any DOS file.
  312.  
  313.  
  314.  
  315.                                             4
  316.  
  317.  
  318.  
  319.  
  320.             THE PORT REGISTERS
  321.             The 8250 port is fully programmable.  LiteComm has already taken
  322.             care of the intricacies of this programming. But some additional
  323.             information about each register used in the serial port may be of
  324.             use when you are attempting to communicate with an external de-
  325.             vice. For the sake of this discussion, we use the basic register
  326.             numbers. The actual register number used is the register number
  327.             referenced below used as an offset to a base port number. For
  328.             COM1 (port 1), this base is 3F8(hexadecimal).
  329.  
  330.  
  331.             register 0 - transmit/receive            register 0 - transmit/receive            register 0 - transmit/receive
  332.             In normal operation, the ISR reads individual characters from
  333.             register 0 when the become available. The ISR writes to register
  334.             0 when the transmitter portion of the 8250 is ready to accept a
  335.             character.
  336.  
  337.             register 0 - baud rate selection            register 0 - baud rate selection            register 0 - baud rate selection
  338.  
  339.             During initialization, register 0 is part of the mechanism that            sets baud rate.  During this process, register 0 and its compan-
  340.             ion register 1 specify the baud rate divisor (not the actual baud
  341.             rate). The baud rate divisor is a value that, when divided into a
  342.             given, preset constant, yields the desired baud rate.  To set the
  343.             baud rate, you must first enable access to this mode. This is
  344.             done by writing a value of 80H to register 3, the line control
  345.             register.  Once complete, the least significant byte (LSB) of the
  346.             divisor is written to register 0; the most significant byte is
  347.             written to register 1.  Access to the normal modes of registers 0
  348.             and 1 are reenabled by writing any value less than 80H to the
  349.             line control register.  Of course, only certain values less than
  350.             80H would be meaningful (see the line control register descrip-
  351.             tion below).
  352.  
  353.  
  354.             register 1 - interrupt enable            register 1 - interrupt enable            register 1 - interrupt enable
  355.             Values written to register 1 control the conditions that will
  356.             cause the 8250 to interrupt the system. There are four possible
  357.             conditions that can cause interrupts:
  358.  
  359.  
  360.             1. A character has been received (RDI)                                             (RDI)                                             (RDI)
  361.             2. The transmitter is ready to send a character (TDI)                                                            (TDI)                                                            (TDI)
  362.             3. An error or BREAK signal has been detected (ERI)                                                          (ERI)                                                          (ERI)
  363.  
  364.             4. A modem status  signal has changed (MSI)                                                  (MSI)                                                  (MSI)
  365.  
  366.             The designations, in parentheses, are for our purposes only. They
  367.             are not 'standard' designations. To enable a particular type of
  368.             interrupt, you must set the corresponding bit in a byte to a 1,
  369.             then write the byte to register 1.  To reset (ignore) the condi-
  370.             tion, set the corresponding bit to 0.  The diagram that follows
  371.             shows the bit positions the correspond to the various conditions
  372.             described above.
  373.  
  374.  
  375.  
  376.  
  377.                                             5
  378.  
  379.  
  380.  
  381.  
  382.                 N/A    N/A    N/A    N/A   Modem  Error/  Xmit   Recv
  383.                                            Status Break  Ready   Char
  384.                  7      6      5      4      3      2      1      0
  385.             Register 1 Bit Definitions
  386.  
  387.  
  388.             register 1 - baud rate selection            register 1 - baud rate selection            register 1 - baud rate selection
  389.  
  390.             See the description under register 0, baud rate selection.
  391.  
  392.  
  393.             register 2 - interrupt identification            register 2 - interrupt identification            register 2 - interrupt identification
  394.  
  395.             Register 2, in normal operation, acts as a companion to register
  396.             1.  Register 1 determines the conditions that can cause an
  397.             interrupt.  Register 2 identifies the specific condition that
  398.             caused the interrupt, when more than one condition is enabled.
  399.             The least significant 3 bits of the register contain the identi-
  400.             fication.  See the diagram of register 2 that follows.
  401.  
  402.  
  403.                 N/A    N/A    N/A    N/A    N/A   Int ID Int ID  Int
  404.                                                                  Pend
  405.                  7      6      5      4      3      2      1      0
  406.             Register 2 Bit Definitions
  407.  
  408.  
  409.             Since it is possible, even likely, that more than one condition
  410.             may occur simultaneously, bit 0 tells whether all conditions that
  411.             currently exist have been handled.  When bit 0 has a value of 0
  412.             (yes zero), there are conditions waiting to be handled.  When bit
  413.             0 has a value of 1, all outstanding conditions have been handled.
  414.             Bits 2 and 1 taken together identify the actual cause of the in-
  415.             terrupt.
  416.  
  417.             Again, because of the multiple conditions that may occur, the
  418.             8250 presents the conditions in a prioritized order.  When bits 2
  419.             and 1 have a value of 3 (the most important), an ERI                                                             ERI                                                             ERI condition
  420.             exists. The actual error can be read from the line status regis-
  421.             ter(register 5). Reading this register also clears the condition.
  422.  
  423.  
  424.             When a value of 2 is present, an RDI                                              RDI                                              RDI condition has occurred, and
  425.             a character should be read from port 0. If the character is not
  426.             read quickly enough, a data overrun error may occur, indicating
  427.             the loss of a character.
  428.  
  429.             When bits 2 and 1 have a value of 1, a TDI                                                    TDI                                                    TDI condition has occurred
  430.             and a character may be written to register 0.
  431.  
  432.  
  433.             A value of zero in bits 2 and 1(least important) shows that one
  434.             or more of the modem status lines (so called) have changed. The
  435.             condition can be cleared by reading the contents of the modem
  436.             status register, register 6.
  437.  
  438.  
  439.                                             6
  440.  
  441.  
  442.  
  443.  
  444.             register 3 - line control            register 3 - line control            register 3 - line control
  445.             The line control register gives the means for setting those val-
  446.             ues that affect the way in which the serial port appears to the
  447.             outside world.  It is through this register that the program es-
  448.             tablishes character length, parity, and other significant values.
  449.             Indirectly, register 3 also plays a role in setting the speed
  450.             (baud rate) of the port. (See the description of registers 0 and
  451.             1.)
  452.  
  453.  
  454.                Baud   Send   Force Parity  Enable  Stop   Char   Char
  455.                 Div   Break Parity  Type   Parity  Bits   Len    Len
  456.                  7      6      5      4      3      2      1      0
  457.             Register 3 Bit Definitions
  458.  
  459.  
  460.  
  461.             register 4 - modem control            register 4 - modem control            register 4 - modem control
  462.             The modem control register permits control of the two modem- re-
  463.             lated signals that the serial port generates as an output.  The
  464.             signals are Request To Send, RTS                                         RTS                                         RTS and Data Terminal Ready, DTR                                                                      DTR                                                                      DTR.
  465.  
  466.  
  467.             These two signals are handshaking signals, since they, in part,
  468.             help a connected device figure out the state of the connection.
  469.             These signals were originally designated to be used in a specific
  470.             fashion. Yet, manufacturers of specific devices have used them to
  471.             meet their needs. Your success or failure in dealing with any
  472.             specific device may depend, in part, on your understanding of how
  473.             the device's manufacturer uses these signals. LiteComm provides
  474.             you the means for manipulating these signals in a variety of
  475.             ways.
  476.  
  477.             You will notice in the register 4 diagram, below that some addi-
  478.             tional positions are identified.
  479.  
  480.  
  481.                 N/A    N/A    N/A  Enable   OUT2   OUT1   RTS    DTR
  482.                                     Loop   (reqd)
  483.                  7      6      5      4      3      2      1      0
  484.             Register 4 Bit Definitions
  485.  
  486.  
  487.             LiteComm controls these additional positions for your benefit.
  488.             Only one deserves mention, the position labeled OUT2                                                            OUT2                                                            OUT2.  It is
  489.             necessary for this position to have a value of 1 for the serial
  490.             port to function as an interrupting device. Since LiteComm relies
  491.             on interrupts to perform it's job, it always sets this position
  492.             correctly.
  493.  
  494.             register 5 - line status            register 5 - line status            register 5 - line status
  495.  
  496.             The program normally reads the line status register when an ERI                                                                        ERI                                                                        ERI
  497.             condition occurs.  Each bit of the character returned has sig-
  498.             nificance, as shown in the accompanying diagram. Using the ap-
  499.             propriate functions in LiteComm, you can interrogate the value in
  500.             this register, and test for the various conditions using the
  501.                                             7
  502.  
  503.  
  504.  
  505.  
  506.             LiteComm- provided definitions. Note that, due to the special
  507.             nature of the BREAK                          BREAK                          BREAK signal, LiteComm treats this one condition as
  508.             a separate entity.
  509.  
  510.                Time   Shift  Hold   Recd   Frame  Parity  Over   Data
  511.                 Out    Reg    Reg   Break  Error  Error   Run   Rec'd
  512.                       Empty  Empty                       Error
  513.                  7      6      5      4      3      2      1      0
  514.  
  515.             Register 5 Bit Definitions
  516.  
  517.             register 6 - modem status            register 6 - modem status            register 6 - modem status
  518.  
  519.             Just as the serial port can generate certain handshaking signals,
  520.             it also can read, and report on the status of similar signals
  521.             that an external device generates.  In their original form, these
  522.             signals had special significance for connections between a
  523.             terminal and a modem. We refer you to our comments, above, about
  524.             present day use of the handshaking signals.
  525.  
  526.             One special note is appropriate here.  The modem status register
  527.             provides two types of information.  The most significant 4 bits
  528.             (see the diagram) show the current state of the 4 covered sig-
  529.             nals.  The least significant 4 bits show which, if any, of the
  530.             signals have changed state (from zero to one, or vice-versa),
  531.             since the last time the register was interrogated.  LiteComm up-
  532.             dates its internal tables with this value in real-time, and re-
  533.             ports the results when asked to do so.  You can test the signals
  534.             individually or in combination using the LiteComm- provided
  535.             definitions.
  536.  
  537.  
  538.                 DCD    RI     DSR    CTS   Delta  Delta  Delta  Delta
  539.                Carr   Ring   Data   Clear   DCD     RI    DSR    CTS
  540.                 Det    Ind  Set Rd  Send
  541.                  7      6      5      4      3      2      1      0
  542.             Register 6 Bit Definitions
  543.  
  544.  
  545.             The LiteComm Connection
  546.             In the design of LiteComm, we have purposely 'hidden' many
  547.             underlying details we presented above. Often, you will have
  548.             little use for this additional information. This is particularly
  549.             true of most of the applications with which you will come into
  550.             contact.  In most applications, you probably will open the port
  551.             or ports, set the necessary parameters and modem control signals,
  552.             and do nothing more than read and write characters using one or
  553.             more of the LiteComm functions.  The beauty of LiteComm's design
  554.             is that its high degree of granularity doesn't force you to pay
  555.             the price of dragging along functions that you are not using.
  556.  
  557.  
  558.             The information that we presented above will help you when  it is
  559.             necessary to communicate with a device that requires special
  560.             handshaking considerations, such as a cash drawer.  You also may
  561.             need the information we presented if you intend to use serial
  562.             ports beyond COM2 (serial port 2).
  563.                                             8
  564.  
  565.  
  566.  
  567.  
  568.  
  569.             Finally, by presenting the information that we have supplied, we
  570.             hope to gain a more informed user.  Communications programming is
  571.             not the black art that some would have you believe, although it
  572.             can easily seem that way at times.  Of the calls we receive with
  573.             questions, more than 75 per cent could be answered by the caller
  574.             himself with a more thorough understanding of the underlying
  575.             concepts and rules.
  576.  
  577.  
  578.        ToolBox NOTES AND WARNINGS
  579.  
  580.             Note:            Note:            Note:Special warning for old-style PC owners
  581.             There is a known problem with serial ports on older systems. Due
  582.             to a problem with old-style 8250 and 16450 UARTS, it is possible
  583.             for the  transmitter to stop functioning. This problem is cuased
  584.             by a loss of interrupts under load. While software workarounds
  585.             exist, we have decided not to include such workarounds in Lite-
  586.             Comm. Inclusion of this logic would result in added overhead to
  587.             all LiteComm users. If you believe you are experiencing this
  588.             problem, please contact us.
  589.  
  590.  
  591.             Note:            Note:            Note:Open Required
  592.             Before you can send or receive information on a serial port using
  593.             the ToolBox, you must use the open function to enable the line.
  594.             This function initializes the UART with the correct parameters,
  595.             and introduces the UART into the interrupt structure of the PC.
  596.             The ToolBox will detect, and report, any errors that you may make
  597.             in selecting the port or specifying the initial parameters. 
  598.  
  599.  
  600.             Note:            Note:            Note:Close Required
  601.             The ToolBox interfaces directly with the interrupt structure of
  602.             the PC. It is critical before exiting a program that has opened a
  603.             serial port that the serial port is closed with the close func-
  604.             tion. Since it is possible for a program to terminate abnormally,
  605.             the open function installs an exit routine that will
  606.             automatically close any open ports.  Good programming practice
  607.             demands that your program should close the ports explicitly.  By
  608.             so doing, you may avoid problems in the future if we find it
  609.             necessary to remove the auto-close functionality. Further, the
  610.             auto-close functionality drops all modem handshaking signals ab-
  611.             solutely, while an explicit close can decide whether to drop
  612.             these signals. If you are unaware of exit functions, check your
  613.             compiler's documentation for the atexit() function for a complete
  614.             explanation. Review the description of the comm_close() function,
  615.             as well.
  616.  
  617.             Failure of the open function can result from several causes, im-
  618.             proper parameters to the open function, a non-existant serial
  619.             port or insufficient memory. The memory is needed for the re-
  620.             quested buffers and related control structures for the port.
  621.             Memory for the transmit and receive buffers as well as the port
  622.             control block is allocated from free memory. It is your
  623.             responsibility to insure that adequate memory is available for
  624.  
  625.                                             9
  626.  
  627.  
  628.  
  629.  
  630.             this purpose.  This requires no particular action on your part.
  631.             If you use LiteComm in combination with other packages, the other
  632.             packages may place specific restrictions on your use of free
  633.             memory.
  634.  
  635.             Note:            Note:            Note:Handshaking Signals
  636.             The ToolBox will, at your option, assert both the DTR and RTS
  637.             signals when you open the port.  If you do not select this option
  638.              you must use the lc_setmdm function to assert (raise) this sig-
  639.             nal.  In addition, some modems and other devices may require you
  640.             to assert either the DTR (Data Terminal Ready) or the RTS (Re-
  641.             quest To Send) signal before they will respond to data.  Please
  642.             note that the use of handshaking signals is HIGHLY hardware-
  643.             dependant.  The ToolBox provides all the functionality necessary
  644.             for you to implement almost any handshaking scheme that might be
  645.             required.
  646.  
  647.  
  648.             WARNING            WARNING            WARNING
  649.             Due to the use of all available interrupt modes of the 8250, one
  650.             user has discovered an unusual set of circumstances that can be
  651.             troublesome.  If the 8250 chip detects an error condition, such
  652.             as a parity error, framing error, or data overrun error, it
  653.             causes an interrupt to which the ToolBox will respond.  If these
  654.             errors occur frequently enough, the ToolBox code will spend too
  655.             much time handling the errors, and lose characters, causing
  656.             additional errors.  If you encounter a situation in which your
  657.             application appears to behave erratically, especially at higher
  658.             speeds, investigate the following table.
  659.  
  660.  
  661.             Possible Error Conditions
  662.                Is the cabling to the other device sound and solidly con-
  663.                nected?
  664.                Are any of the signals in the cable 'floating' or are they all
  665.                properly terminated?
  666.  
  667.  
  668.                Is the other device functioning properly? We have encountered
  669.                situations in which a serial port on some devices tends to be
  670.                sloppy in terms of voltage levels, bit timings, and similar
  671.                problems.  Any, or all, these situations can cause the erratic
  672.                operation to which we referred.
  673.  
  674.             WARNING            WARNING            WARNING
  675.  
  676.             Unless you are very familiar with the interrupt structure of the
  677.             PC, do not attempt to manipulate the interrupt enable flag out-
  678.             side the ToolBox. The ToolBox sets and clears the interrupt en-
  679.             able flag at appropriate times and assumes that it has sole
  680.             control over the flag.
  681.  
  682.             Note:            Note:            Note:Byte Alignment
  683.             Unless otherwise specified, all library functions use byte
  684.             structure alignment. This alignment results from the way in which
  685.             the interrupt handler was developed in assembly language.
  686.  
  687.                                             10
  688.  
  689.  
  690.  
  691.  
  692.  
  693.        NEW IN VERSION 6.00
  694.             In version 6.0, we have again improved on the assembly language
  695.             interrupt handlers.  In addition, there have been significant
  696.             changes in the supporting functions to tighten the code.  The
  697.             result is smaller applications, often able to operate at higher
  698.             baud rates.
  699.  
  700.  
  701.             Other additions to LiteComm in version 6.0 include fully
  702.             automatic flow control using either software or hardware. Both
  703.             variants are programmer-configurable. This should simplify things
  704.             for some users. 
  705.  
  706.             In version 6.0, LiteComm will attempt to insure that you are at-
  707.             tempting to open a valid COM port. If LiteComm believes that the
  708.             port is not valid, it will return an error from comm_opn. The
  709.             addition of a global error variable should help in determining
  710.             the source of the error. See the section on LiteComm functions
  711.             for additional information.
  712.  
  713.  
  714.             And we have addressed an area that we have always considered a
  715.             LiteComm weakness. In previous versions of LiteComm, it was pos-
  716.             sible to detect an receive error globally, yet not know when it
  717.             occurred. With version 6.0, LiteComm now buffers errors in the
  718.             same way that it buffers incoming characters. At your option, you
  719.             can retrieve the error status associated with a character.
  720.  
  721.             There have been numerous, less significant additions to LiteComm,
  722.             as well. Many are the result of user-feedback. Nearly all are
  723.             aimed at making your job simpler.
  724.  
  725.        BEYOND COM2
  726.             THE ToolBox METHODOLOGY
  727.             In the design of the original PC, and in subsequent variations
  728.             such as the PC/AT, there was only provision for two serial ports.
  729.             Many manufacturers of add-in products, both serial ports and in-
  730.             ternal modems have added the capability to support 1 or more
  731.             additional ports beyond the COM2 limit. Generally, this can cause
  732.             problems in the PC since there is no room in the interrupt re-
  733.             quest scheme for additional levels of interrupts. There are no
  734.             designated interrupt vector for other additional ports.
  735.  
  736.  
  737.             The ToolBox approach to resolving these issues is to permit the
  738.             programmer a degree of control over the parameters that govern
  739.             the interrupt mechanism for COM3 and COM4. Specifically, these
  740.             parameters are:
  741.  
  742.             1. The interrupt request (IRQ) bit that is used to mask the 8259
  743.                interrupt controller.
  744.  
  745.             2. The interrupt vector number (not address) to which the port is
  746.                attached.
  747.  
  748.  
  749.                                             11
  750.  
  751.  
  752.  
  753.  
  754.             3. The base i/o register for the port itself. Of course, it we
  755.                assume that the port is an 8250 UART or compatible device.
  756.                Again, the LiteComm ToolBox will not function with non-8250
  757.                type devices.
  758.  
  759.             Before you attempt to use COM3 and/or COM4, you must figure out
  760.             from the port's documentation, the appropriate values for these
  761.             three parameters. As distributed, the ToolBox assumes the
  762.             following:
  763.  
  764.  
  765.  
  766.                               Port         COM 3     COM 4
  767.                              IRQ Bit         4         3
  768.  
  769.                              Vector         0CH       0BH
  770.                           Base Register     3E8H      2E8H
  771.  
  772.  
  773.             You may change any of these values by using the _portchg function
  774.             described below, but only before you open the port with comm_opn.
  775.             Once the port has been opened, _portchg is ineffective. _portchg
  776.             will not work on COM1 or COM2.
  777.  
  778.             At present, LiteComm is not compatible with multiport boards such
  779.             as the Digiboard.  The structure of these boards generally re-
  780.             quires additional programming to be used effectively.  If you
  781.             want to use such a board with LiteComm, please contact us
  782.             directly for information on custom modifications to LiteComm.  We
  783.             have performed such modifications for other LiteComm users.
  784.  
  785.  
  786.             CAUTIONS
  787.             There is an intimate relationship between the IRQ setting and its
  788.             related interrupt vector. In the PC, this relationship is con-
  789.             trolled, in part, by the 8259 interrupt controller that is set
  790.             during BIOS initialization.
  791.  
  792.  
  793.             In brief, the BIOS settings for the PC (and most close compa-
  794.             tibles) establish IRQ0 as vector number 08h, and subsequent IRQ
  795.             levels at increasing vector numbers. These vector numbers (or
  796.             types in INTEL terms) act as a cpu- directed call table to loca-
  797.             tions in the lowest 1K of system memory. We can alter how the
  798.             system responds to a given interrupt by replacing or changing the
  799.             values in the associated vector position to point to a routine
  800.             that we supply.
  801.             Judging from the questions asked by some users of LiteComm, there
  802.             is evidently some misunderstanding about using ports beyond COM2,
  803.             and how this all relates to your hardware. Before you can suc-
  804.             cessfully use COM3 or COM4, you must consider the following:
  805.                Does the hardware permit a change to the base port and/or the
  806.                interrupt vector to which the port responds?  Some expansion
  807.                cards will support changing one and not the other, causing po-
  808.                tential hardware conflicts and lost data. 
  809.  
  810.  
  811.                                             12
  812.  
  813.  
  814.  
  815.  
  816.                Does the hardware permit  reassignment of the IRQ priority?
  817.                Some expansion cards permit you to alter the IRQ priority,
  818.                some won't. Briefly, from the previous discussion, any change
  819.                to the IRQ priority must allow a corresponding change to the
  820.                interrupt vector number. Without this capability, reprogram-
  821.                ming of the 8259 chip would be required. 
  822.                Many add-on cards permit this dual change simply by making a
  823.                single switch or jumper setting. Unfortunately, the documenta-
  824.                tion for these cards  generally assumes that you are aware of
  825.                the dual nature of the IRQ vector relationship, and may leave
  826.                you with the impression that you are changing one and not the
  827.                other. In most circumstances, this is not so.
  828.  
  829.             The point to all this is that LiteComm can only provide as much
  830.             support as the hardware permits, or is capable of responding to.
  831.             If you wish to use other than the default base port, interrupt
  832.             vector, or irq priority for COM3 or COM4, then your expansion
  833.             card must be able to support the new values; in other words,
  834.             these values are all hardware-provided, and are recognized by the
  835.             LiteComm software. If your hardware does not permit changing a
  836.             value, LiteComm cannot improve the situation.
  837.  
  838.  
  839.             We should, at this point, add one final caution about how inter-
  840.             rupt priorities function, and their relationship to the irq bit
  841.             that you may select. The standard PC permits 8 interrupt priority
  842.             levels. The PC-AT and later systems permit a total of 16 inter-
  843.             rupt priority levels. Regardless of system type, the programmable
  844.             timer has the highest priority; the parallel printer port has the
  845.             lowest priority. When an interrupt occurs, the interrupt
  846.             controller (8259 chip) masks out all other interrupts from the
  847.             priority of the interrupting device and all lower priority de-
  848.             vices. 
  849.  
  850.             As an aid to making COM3 and COM4 fit, LiteComm supports inter-
  851.             rupt chaining for the COM3 and COM4 ports, on PS/2 and other mi-
  852.             crochannel systems. If you use COM3 or COM4, when an interrupt
  853.             occurs, the kernel will attempt to determine if the interrupt was
  854.             caused by the supported port or from another source. Only the
  855.             PS/2 and similar systems can reliably support interrupt chaining;
  856.             it is NOT a restriction that we impose. The restriction lies in
  857.             the design of the original PC and PC-AT buss structure.
  858.  
  859.  
  860.             If the kernel determines that the supported port did not cause
  861.             the interrupt, an automatic chain to the original interrupt han-
  862.             dler for that interrupt level (IRQ level) will take place. This
  863.             allows you to "patch in" or share the available interrupt vec-
  864.             tors.
  865.  
  866.             If you intend to use other than the library-provided defaults, be
  867.             sure that you understand the interrupt mechanism. The use of the
  868.             automatic chaining described above can be particularly trouble-
  869.             some under some circumstances, resulting in loss of interrupts
  870.             and, potentially, a system crash.
  871.  
  872.  
  873.                                             13
  874.  
  875.  
  876.  
  877.  
  878.             Note:            Note:            Note:DO NOT                  DO NOT                  DO NOT attempt to mix the ToolBox functions with other
  879.             seemingly- related functions (such as the serial port BIOS calls
  880.             provided in both Turbo and Microsoft C).  At least two users have
  881.             attempted to use only the receive portions of LiteComm, while
  882.             resorting to the BIOS functions to send characters or adjust port
  883.             parameters such as baud rate. The results, at best, have been
  884.             failure of the user's application to function, and, at worst,
  885.             total system lockup.  This mix of functions is NOT supported and
  886.             must not be used.  If you attempt such a mix, we cannot help you.
  887.  
  888.             If you chose to share the interrupt vectors for COM1 or COM2, you
  889.             must be certain to open COM1 (COM2) last.  The interrupt chaining
  890.             mechanism only works with COM3 and COM4.  Failure to follow this
  891.             caution will result in a total loss of function of COM3 (COM4).
  892.             In addition, the ports should be opened in descending order of
  893.             the planned baud rate, i.e. the faster port should be opened
  894.             first, the slower port should be opened last.  Whenever possible
  895.             or practical, you will obtain best results by using the same baud
  896.             rate on both ports.
  897.  
  898.  
  899.             One final caution is in order.  One or two users have attempted
  900.             to trace through the interrupts as they occur using software
  901.             based debuggers.  This is a risky proposition at best since most
  902.             debuggers work by tapping into, and disturbing, the interrupt
  903.             mechanism.  If you feel you must use a debugger, try to avoid the
  904.             kernel routines of LiteComm, or use a hardware-based debugger
  905.             such as Periscope.
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.                                             14
  936.  
  937.  
  938.  
  939.  
  940.        INSTALLATION
  941.  
  942.  
  943.        PACKAGE CONTENTS
  944.             Your distribution diskette contains many files that are important
  945.             to you. See the file PACKING.LST on the distribution disk for a
  946.             list of the files that you should have received.
  947.  
  948.        INSTALLING LITECOMM
  949.             LiteComm is installed with the INSTALL utility that we provide on
  950.             the distribution diskette. To use this utility, follow the easy
  951.             steps below:
  952.  
  953.  
  954.             1. Make a copy of the distribution diskette before beginning.
  955.             2. Insert the distribution diskette in your diskette drive.
  956.             3. Make the distribution diskette the default drive by typing ei-
  957.                ther A:<ENTER> or B:<ENTER>.
  958.             4. Type the command
  959.  
  960.                  INSTALL<ENTER>.
  961.  
  962.             INSTALL will present you with a screen that specifies the in-
  963.             stallation default values. You may freely edit them before pro-
  964.             ceeding with the installation. Use the arrow keys to move between
  965.             the various options. When you are satisfied with your responses,
  966.             press the <PAGE-DOWN> key to proceed with installation.
  967.  
  968.  
  969.             INSTALL will create several directories on the target disk drive.
  970.             These directories do not have to exist before you start INSTALL.
  971.             After copying the necessary files, INSTALL will decompress the
  972.             files into their final form and clean up after itself.
  973.             By default, install will create the following directories:
  974.                             LITECOMM          Header Files
  975.  
  976.                           LITECOMM\LIB     PreBuilt Libraries
  977.                          LITECOMM\SOURCE   Package Source Code
  978.  
  979.  
  980.             If you prefer, of course, you may install LiteComm manually by
  981.             copying all of the distributed EXE files to your destination
  982.             disk. Then execute each to decompress it, with the exception of
  983.             INSTALL. Finally, delete each of the EXE files to clean up your
  984.             disk. They will no longer be needed.
  985.        REBUILDING THE LIBRARIES
  986.             We have provided you with the source code for LiteComm so that
  987.             you may modify our product to meet special needs. We encourage
  988.             you to use the provided MAKE files to accomplish this. They were
  989.             used in constructing the libraries you have just installed and
  990.             will make the task decidedly simpler.  the make files for Turbo C
  991.             are TURBOCOMM.MAK and TLCP.MAK. The make files for Microsoft C
  992.             are MSCCOMM.MAK and MLCP.MAK. 
  993.  
  994.  
  995.  
  996.  
  997.                                             15
  998.  
  999.  
  1000.  
  1001.  
  1002.             We have had a report from one user that the make files are not
  1003.             compatible with the version of the make utility provided with the
  1004.             IBM C compiler, even though IBM's product is derived from Micro-
  1005.             soft C. Unfortunately, we do not support the IBM product as we
  1006.             have no way of assuring compatibility. We do understand, however,
  1007.             that the Microsoft libraries are fully compatible.
  1008.             GENERAL NOTES
  1009.             LiteComm and its related libraries make extensive use of parame-
  1010.             ters defined in the included header files. Your programs should
  1011.             always use the same header file parameters. While every effort
  1012.             will be made in future releases of LiteComm to preserve the val-
  1013.             ues as currently provided, we cannot guarantee that changes will
  1014.             never occur. The surest way to safeguard your efforts is to use
  1015.             the defined parameters. Then, when new versions of LiteComm are
  1016.             released, you need only recompile and relink to insure
  1017.             consistency.
  1018.  
  1019.  
  1020.             In the discussion of the various functions that follows, you
  1021.             should assume that any references to the port variable refer to a
  1022.             variable or constant that may take on a value of from 1 to 4. No
  1023.             other values are acceptable, and will be rejected.
  1024.  
  1025.             While we feel that LiteComm is written in the most efficient way
  1026.             possible, commensurate with good programming practice, we cannot
  1027.             be responsible for variations caused by hardware configurations
  1028.             or other factors beyond our control. LiteComm has been tested on
  1029.             the IBM PC-AT, IBM PS/2 and several compatible systems such as
  1030.             the Zenith and Wyse equivalents. LiteComm has not been tested in
  1031.             environments in which other software, most significantly TSR
  1032.             (terminate and stay resident) modules exist. Some TSR programs
  1033.             that "steal" interrupts for their purposes present an unfavorable
  1034.             environment to other programs that rely on the interrupt struc-
  1035.             ture of the computer.
  1036.  
  1037.  
  1038.             If you experience erratic behavior with LiteComm in a TSR-type
  1039.             situation, try executing your application without the TSR module
  1040.             being present. If the problems you have experienced disappear,
  1041.             suspect the TSR module.
  1042.  
  1043.             Conversely, LiteComm provides an excellent vehicle for supporting
  1044.             TSR programs that you may write. Since the package is fully
  1045.             reentrant, your only concern need be with those aspects of TSR
  1046.             programs are of normal concern, e.g., the non reentrant nature of
  1047.             DOS. 
  1048.             LiteComm only uses DOS functions when opening and closing ports.
  1049.             It may therefore be safely used in a TSR environment. As an
  1050.             example, we have included the program SPM as part of this re-
  1051.             lease.  SPM is a background Serial Port Monitor that is available
  1052.             as a separate shareware product. SPM was developed using Lite-
  1053.             Comm.
  1054.  
  1055.             USE WITH MULTITASKING ENVIRONMENTS
  1056.             Some users have made attempts at using LiteComm with multitasking
  1057.             environments such as Quarterdesk's DesqView.  Use of LiteComm in
  1058.  
  1059.                                             16
  1060.  
  1061.  
  1062.  
  1063.  
  1064.             such an environment is certain to be affected by the way in which
  1065.             the multitasking behaves with respect to interrupts.  We recog-
  1066.             nize that DesqView has achieved a great deal of popularity among
  1067.             so-called power users. Still, LiteComm was not explicitly de-
  1068.             signed for such environments, and its performance may suffer as a
  1069.             result.
  1070.             NOTES ON RING DETECTION
  1071.             Several users have reported problems in consistently detecting a
  1072.             ringing telephone by checking the state of the RI (Ring Indica-
  1073.             tor) signal.  The problem seems highly dependent on the type of
  1074.             modem that is being used, since this signal comes from the modem.
  1075.             If the duration of the signal is too short, the program may miss
  1076.             the signal as the modem toggles it.  One workaround that has been
  1077.             successfully is to check the RICHG bit returned from lc_mstat,
  1078.             rather than the RI bit.  The RICHG bit will be set when the RI
  1079.             bit comes one and again when the RI bit goes off. This is the
  1080.             method employed in the check_for_call function.
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.                                             17
  1122.  
  1123.  
  1124.  
  1125.  
  1126.        FUNCTION REFERENCE
  1127.  
  1128.  
  1129.             GENERAL INFORMATION
  1130.             In the following pages, we provide the detailed information about
  1131.             each available LiteComm ToolBox function.  Each function defini-
  1132.             tion includes, at a minimum, a summary of how to code the func-
  1133.             tion, a description of what the function does, and an indication
  1134.             of those values, if any, that the function might return.
  1135.  
  1136.  
  1137.             Where appropriate, we include additional documentation about the
  1138.             function.  Some definitions include examples, in the sense of
  1139.             code fragments illustrating the function's usage.  More impor-
  1140.             tantly, some definitions include additional notes and warnings as
  1141.             well as references to other functions within the package.
  1142.  
  1143.             We have made every effort to insure that the documentation of the
  1144.             functions is complete and accurate.  The style and manner of the
  1145.             documentation assume that the reader is thoroughly familiar with
  1146.             the elements of C syntax and common conventions.
  1147.  
  1148.  
  1149.             FLOW CONTROL
  1150.             In version 6 of LiteComm, we have incorporated fully automatic
  1151.             flow control, using either software, sometimes called XON-XOFF
  1152.             control, or hardware using the handshaking signals. 
  1153.             Note:            Note:            Note:It is not valid to have both methods of flow control active
  1154.             at the same time. Failure to observe this restriction can cause
  1155.             unpredictable results.
  1156.             GLOBAL ERROR VARIABLE
  1157.  
  1158.             Version 6 of LiteComm has a global error variable that is set by
  1159.             each of the LiteComm functions. The variable, _lc_error                                                          _lc_error                                                          _lc_error, is de-
  1160.             fined in LITECOMM.H. Possible values are in the file LITE-
  1161.             COMM.ERR. Examining the contents of _lc_error can help you
  1162.             diagnose and correct problems.
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.                                             18
  1184.  
  1185.  
  1186.  
  1187.  
  1188.        _portchg
  1189.  
  1190.  
  1191.             SUMMARY
  1192.             #include <litecomm.h>
  1193.  
  1194.             int _portchg(port, base, irq, vector)
  1195.             unsigned port;
  1196.             unsigned base;
  1197.             unsigned vector;
  1198.  
  1199.             char irq;
  1200.             DESCRIPTION
  1201.             Changes one or more of the critical parameters for COM3 or COM4.
  1202.             This function must be used before the opening port to be effec-
  1203.             tive. To leave any of the parameters at its default value, make
  1204.             the corresponding entry 0. Note that vector is a vector number,
  1205.             not an address or pointer.
  1206.             The irq parameter is NOT the irq (interrupt request) number, but
  1207.             the irq mask. The following lines, reproduced from 'litecomm.h'
  1208.             help illustrate this idea.
  1209.  
  1210.             #define IRQ1 0x10 /* int req mask for port 1 - irq4 */
  1211.             #define IRQ2 0x08 /* int req mask for port 2 - irq3 */
  1212.             Note:            Note:            Note:The value for irq4 is NOT 4, but a character in which bit 4,
  1213.             using INTEL's bit numbering, has a value of 1. Thus, to use irq
  1214.             priority 1 as the irq for either COM3 or COM4, you would specify
  1215.             0x02 as the value of irq when calling _portchg.
  1216.             The default parameters are in the litecomm.h include file.
  1217.  
  1218.             If you intend to change the default irq settings, you also MUST                                                                       MUST                                                                       MUST
  1219.             make a corresponding change to the vector number. See the accom-
  1220.             panying documentation about using COM3 and COM4 for additional
  1221.             details. Failure to follow this rule may make the port appear to
  1222.             be nonfunctional.
  1223.             The _portchg function does NOT check to determine that you have
  1224.             provided both an IRQ mask AND a new vector number.
  1225.  
  1226.             Example            Example            Example
  1227.  
  1228.  
  1229.                  if (_portchg(port, 0x408, 0, 0, 0) == -1)
  1230.                  {
  1231.                       printf("Error Changing Port %d\n", port);
  1232.                       exit(1);
  1233.                  }
  1234.  
  1235.  
  1236.             RETURN VALUES
  1237.             Returns 0 if the function is successful, -1 if you attempt to
  1238.             change a port other that 3 or 4.
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.                                             19
  1246.  
  1247.  
  1248.  
  1249.  
  1250.        comm_opn
  1251.  
  1252.  
  1253.             SUMMARY
  1254.             #include <litecomm.h>
  1255.  
  1256.             int comm_opn(port, baud, parity, datab, stopb, inbufsz, outbufsz,
  1257.             raisemdm)
  1258.             unsigned port;
  1259.             unsigned baud;
  1260.             unsigned parity;
  1261.  
  1262.             unsigned datab;
  1263.             unsigned stopb;
  1264.             unsigned inbufsz;
  1265.             unsigned outbufsz;
  1266.  
  1267.             DESCRIPTION
  1268.             Opens the specified port for use and attaches an interrupt han-
  1269.             dler to DOS for the port. Optionally, comm_opn will raise the DTR
  1270.             and RTS modem control signals, if the value of raisemdm is TRUE.
  1271.             The function allocates, from the heap, space for the CCB (com-
  1272.             munications control block), space for the interrupt handler's
  1273.             stack, and buffers for input and output of the specified sizes.
  1274.             The minimum value for inbufsz is 128; the minimum size for out-
  1275.             bufsz is 64.
  1276.             If sufficient memory is available and the parameters are correct,
  1277.             the port will be set to the parameters (baud rate, word length,
  1278.             stop bits) used when the function is called.  The memory overhead
  1279.             associated with opening a port can be approximated by adding
  1280.             about 1.2K bytes to the buffer sizes specified.
  1281.             comm_opn installs an exit handler using the atexit() function to
  1282.             protect DOS from problems that might arise if a program using
  1283.             LiteComm fails. Still, it is sound practice to close a port
  1284.             opened in this manner using comm_close explicitly in your program
  1285.             to gain maximum control over the port.
  1286.  
  1287.             The baud parameter is an unsigned integer that specifies the baud
  1288.             rate you intend to use, e.g., 4800. The other parameters passed
  1289.             to the function should be from the parameter set in the lite-
  1290.             comm.h include file.
  1291.  
  1292.  
  1293.             Example            Example            Example
  1294.  
  1295.             Below are two examples of using comm_opn, the first letting
  1296.             comm_opn raise the modem control signals, the second using two
  1297.             function calls to do the same thing.  The result of each example
  1298.             is the same, an open port on which the DTR and RTS signals have
  1299.             been raised.
  1300.             Example 1            Example 1            Example 1
  1301.             if (comm_opn(port, 1200, NPARITY, BIT8, STOP1, 256,
  1302.                     256, TRUE) == - 1)
  1303.             {
  1304.                  printf("Error Opening Port %d\n", port);
  1305.                  exit(1);
  1306.  
  1307.                                             20
  1308.  
  1309.  
  1310.  
  1311.  
  1312.             }
  1313.             Example 2            Example 2            Example 2
  1314.             if (comm_opn(port, 1200, NPARITY, BIT8, STOP1, 256,
  1315.                     256, FALSE) == - 1)
  1316.             {
  1317.  
  1318.                  printf("Error Opening Port %d\n", port);
  1319.                  exit(1);
  1320.             }
  1321.             lc_setmdm(port, (DTR | RTS));
  1322.  
  1323.  
  1324.             RETURN VALUES
  1325.             Upon successful open, the function returns port. If any error
  1326.             occurs, despite the type, the function returns -1.
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.                                             21
  1370.  
  1371.  
  1372.  
  1373.  
  1374.        comm_close
  1375.  
  1376.  
  1377.             SUMMARY
  1378.             #include <litecomm.h>
  1379.  
  1380.             int comm_close(port, dropmdm)
  1381.             unsigned port;
  1382.             DESCRIPTION
  1383.             This function is the companion to comm_opn and, in effect, per-
  1384.             forms the opposite action. Comm_close detaches the library rou-
  1385.             tines from the interrupt handler, and reconnects the previous
  1386.             interrupt handler.
  1387.  
  1388.             Comm_close also releases all allocated memory used for the buff-
  1389.             ering and control structures described under comm_opn. If the
  1390.             value of dropmdm is non-zero, the port is closed absolutely, and
  1391.             all modem control signals are dropped.  If the value of dropmdm
  1392.             is zero, the port is closed conditionally, and both the DTR and
  1393.             RTS signals will be left in their current state. 
  1394.             Since comm_opn installs an exit handler using the atexit function
  1395.             in both Turbo C and Microsoft C, you are not required to close
  1396.             explicitly an open port.  However, if you do not explictly close
  1397.             the port, you will lose control over the handling of the DTR and
  1398.             RTS signals since the built-in exit handler uses the absolute
  1399.             form of the close.
  1400.  
  1401.             Example            Example            Example
  1402.  
  1403.             These are two equivalent examples of the comm_close function.
  1404.             The first uses the absolute port close, the second uses two
  1405.             function calls to do the same thing.
  1406.             Example 1            Example 1            Example 1
  1407.             comm_close(port, TRUE);       /* absolute close */
  1408.             Example 2            Example 2            Example 2
  1409.             lc_clrmdm(port, (RTS | DTR));  /* lower modem control */
  1410.             comm_close(port, FALSE); /* conditional close */
  1411.  
  1412.             RETURN VALUES
  1413.             If any error occurs, despite the type, the function returns -1.
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.                                             22
  1432.  
  1433.  
  1434.  
  1435.  
  1436.        comm_setup
  1437.  
  1438.  
  1439.             SUMMARY
  1440.             #include <litecomm.h>
  1441.  
  1442.             int comm_setup(port,baud,parity,datab,stopb)
  1443.             unsigned port;
  1444.             unsigned baud;
  1445.             unsigned parity;
  1446.  
  1447.             unsigned datab;
  1448.             unsigned stopb;
  1449.             DESCRIPTION
  1450.             The comm_setup function is a subset of the comm_opn function and
  1451.             the remarks made in the description of comm_opn regarding the
  1452.             port parameters apply.
  1453.  
  1454.             This function is useful if you wish to change the basic commu-
  1455.             nication parameters of the specified port that has already been
  1456.             opened without comm_close'ing the port.
  1457.  
  1458.  
  1459.             Example            Example            Example
  1460.  
  1461.             if (comm_setup(port, 1200, NPARITY, BIT8, STOP1) == 
  1462.                  -1)
  1463.             {
  1464.                  printf("Error Changing Port %d\n", port);
  1465.                  exit(1);
  1466.             }
  1467.  
  1468.  
  1469.             RETURN VALUES
  1470.             If any error occurs, despite the type, the function returns -1.
  1471.             SEE ALSO
  1472.  
  1473.             comm_opn
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.                                             23
  1494.  
  1495.  
  1496.  
  1497.  
  1498.        lc_vport
  1499.  
  1500.  
  1501.             SUMMARY
  1502.             #include <litecomm.h>
  1503.  
  1504.             COMM *lc_vport(port)
  1505.             DESCRIPTION
  1506.             lc_vport is a macro that validates that the port number specified
  1507.             is correct and has been opened with the comm_opn function. It may
  1508.             be of use to you in writing certain applications.
  1509.  
  1510.             RETURN VALUES
  1511.             If the port is valid and has been opened, returns a pointer to
  1512.             the CCB (communications control block) for the port. Returns NULL
  1513.             if an error occurs;
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.                                             24
  1556.  
  1557.  
  1558.  
  1559.  
  1560.        lc_icnt, lc_ocnt
  1561.  
  1562.  
  1563.             SUMMARY
  1564.             #include <litecomm.h>
  1565.  
  1566.             int lc_icnt(port)
  1567.             int lc_ocnt(port)
  1568.             unsigned port;
  1569.             DESCRIPTION
  1570.  
  1571.             These functions may be used to determine the number of characters
  1572.             currently in the input(lc_icnt) or output(lc_ocnt) buffers for
  1573.             the port.
  1574.  
  1575.  
  1576.             Example            Example            Example
  1577.  
  1578.             #include <litecomm.h>
  1579.             if (lc_icnt(port))       /* anything received ? */
  1580.                 puts("Characters waiting in input");
  1581.  
  1582.  
  1583.             RETURN VALUES
  1584.             Both functions return -1 if an error occurs (port not open or
  1585.             invalid port number). The lc_icnt() function returns the number
  1586.             of characters in the input buffer; lc_ocnt() returns the number
  1587.             of characters remaining in the transmit buffer.
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.                                             25
  1618.  
  1619.  
  1620.  
  1621.  
  1622.        lc_mstat
  1623.  
  1624.  
  1625.             SUMMARY
  1626.             #include <litecomm.h>
  1627.  
  1628.             int lc_mstat(port)
  1629.             unsigned port;
  1630.             DESCRIPTION
  1631.             May be used to determine the last known state of the modem-
  1632.             supplied handshake signals. These may be tested using the values
  1633.             in the include file litecomm.h. 
  1634.  
  1635.             The handshake signals consist of a byte in which the bits 4-7
  1636.             contain the current state of the signals (such as Clear To Send
  1637.             or CTS). Bits 0-3 contain information regarding whether
  1638.             individual signals have changed. lc_mstat always returns the
  1639.             current values of the signals in bits 4-7.  Bits 0-3 will reflect
  1640.             which, if any, of the signals has changed.  
  1641.             The easiest approach to dealing with the returned value is to
  1642.             test bits 0-3 (the DELTA or change bits) for a non-zero value.
  1643.             If any non-zero value is found in bits 0-3, one or more signals
  1644.             have changed _____ ___ ____ ____ __ ________                         since the last call to lc_mstat.  
  1645.             Note:            Note:            Note:The functions resets the DELTA bits.  The value obtained
  1646.             from bits 4- 7 will correctly reflect the current state of the
  1647.             signals.
  1648.             To examine individual signals, litecomm.h has #defined symbols
  1649.             for the change bits ,e.g., CTSCHG, and for the signals themselves
  1650.             ,e.g.. CTS. 
  1651.  
  1652.  
  1653.  
  1654.             Example            Example            Example
  1655.             int curstat;
  1656.  
  1657.             curstat = lc_mstat(port);            /* get curent values */
  1658.  
  1659.             if (curstat & DCDCHG)         /* DCD changed ? */
  1660.                 if (! (curstat & DCD))
  1661.             /* carrier still on */
  1662.                    puts("Remote is off-line, carrier lost");
  1663.  
  1664.  
  1665.             RETURN VALUES
  1666.             If the port is valid and open, returns the current modem status
  1667.             bits. Returns -1 if an error occurs.
  1668.             SEE ALSO
  1669.             lc_got???
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.                                             26
  1680.  
  1681.  
  1682.  
  1683.  
  1684.        lc_got???
  1685.  
  1686.  
  1687.             SUMMARY
  1688.             #include "litecomm.h"
  1689.  
  1690.             unsigned port;
  1691.             lc_gotcts(port);
  1692.             lc_gotdsr(port);
  1693.             lc_gotri(port);
  1694.  
  1695.             lc_gotdcd(port);
  1696.             lc_gotctschg(port);
  1697.             lc_gotdsrchg(port);
  1698.             lc_gotrichg(port);
  1699.  
  1700.             lc_gotdcdchg(port);
  1701.  
  1702.             DESCRIPTION
  1703.             This set of 8 macros makes the job of testing the individual mo-
  1704.             dem status signals simpler.
  1705.  
  1706.             The macros rely upon the lc_mstat function and you should refer
  1707.             to the description of that function for additional information.
  1708.             SEE ALSO
  1709.             lc_mstat
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.                                             27
  1742.  
  1743.  
  1744.  
  1745.  
  1746.        lc_estat
  1747.  
  1748.  
  1749.             SUMMARY
  1750.             #include <litecomm.h>
  1751.  
  1752.             int lc_estat(port)
  1753.             unsigned port;
  1754.             DESCRIPTION
  1755.             May be used to determine the last known state of the serial
  1756.             port's error status bits. These may be tested using the values in
  1757.             the include file litecomm.h.
  1758.  
  1759.             The errors that are detected and reported include:
  1760.             ORUNERR - failure to fetch a character from the port before the
  1761.             next character arrived.  Usually a problem in the interrupt han-
  1762.             dler.
  1763.             PARERR - One or more characters were received in which the parity
  1764.             of the character(s) did not match the current parity setting of
  1765.             the port.  Can be caused by line noise, or by other causes.
  1766.             FRMERR - A framing error has occurred.  A character arrived that
  1767.             had too few or (more likely) too many bits.  Usually caused by
  1768.             line noise.
  1769.  
  1770.             RETURN VALUES
  1771.             If the port is valid and open, returns the current error status
  1772.             bits. Returns -1 if an error occurs.
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.                                             28
  1804.  
  1805.  
  1806.  
  1807.  
  1808.        lc_getw
  1809.  
  1810.  
  1811.             SUMMARY
  1812.             #include <litecomm.h>
  1813.  
  1814.             int lc_getw(port)
  1815.             unsigned port;
  1816.             DESCRIPTION
  1817.             Reads a character from the serial port's input buffer. Waits in-
  1818.             definitely until a character is available.  If the port is dis-
  1819.             connected for any reason, this function will cause a system hang
  1820.             if called, so its use should be carefully controlled.
  1821.  
  1822.             RETURN VALUES
  1823.             Returns the next available character in the input buffer for the
  1824.             port. Returns -1 if the port is not active, or if an invalid port
  1825.             number is specified.
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.                                             29
  1866.  
  1867.  
  1868.  
  1869.  
  1870.        lc_setmdm
  1871.  
  1872.  
  1873.             SUMMARY
  1874.             #include <litecomm.h>
  1875.  
  1876.             int lc_setmdm(port, newset)
  1877.             unsigned port;
  1878.             unsigned newset;
  1879.             DESCRIPTION
  1880.  
  1881.             Set one or more of the modem control signals. Because of the need
  1882.             to have OUT2 set for interrupt support, the function always pro-
  1883.             vides the correct setting for this bit. Use the symbolic #defines
  1884.             found in the litecomm.h file.  Many applications will not require
  1885.             this function, if they allow comm_opn to raise these two signals.
  1886.             More sophisticated applications may be required to control either
  1887.             or both of the signals to provide handshaking with an external
  1888.             device.
  1889.  
  1890.  
  1891.             Example            Example            Example
  1892.  
  1893.             /* raise the RTS modem control signal */
  1894.                  lc_setmdm(port, RTS);
  1895.             /* raise both RTS and DTR */
  1896.                  lc_setmdm(port, (RTS | DTR));
  1897.  
  1898.  
  1899.             RETURN VALUES
  1900.             Returns 0 if the operation was successful, returns -1 otherwise.
  1901.             SEE ALSO
  1902.             comm_opn, lc_clrmdm, lc_togmdm, lc_setdtr, lc_setrts 
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.                                             30
  1928.  
  1929.  
  1930.  
  1931.  
  1932.        lc_setdtr, lc_setrts
  1933.  
  1934.  
  1935.  
  1936.             SUMMARY
  1937.  
  1938.             #include "litecomm.h"
  1939.             unsigned port;
  1940.             lc_setdtr(port);
  1941.             lc_setrts(port);
  1942.  
  1943.             DESCRIPTION
  1944.             lc_setdtr and lc_setrts are macros designed to help make your
  1945.             code more explicit. Both macros use the lc_setmdm function to set
  1946.             the DTR and RTS signals. Note that no effort is made to preserve
  1947.             the current modem signal status. That is use of the lc_setdtr
  1948.             macro will cause RTS to drop. The  converse is true of lc_setrts.
  1949.             SEE ALSO
  1950.             lc_setmdm
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.                                             31
  1990.  
  1991.  
  1992.  
  1993.  
  1994.        lc_clrmdm
  1995.  
  1996.  
  1997.             SUMMARY
  1998.             #include <litecomm.h>
  1999.  
  2000.             int lc_clrmdm(port, newset)
  2001.             unsigned port;
  2002.             unsigned newset;
  2003.             DESCRIPTION
  2004.  
  2005.             Companion to the setmdm function. Clears the modem control sig-
  2006.             nals RTS or DTR or both. Because of the need to have OUT2 set for
  2007.             interrupt support, the function always provides the correct set-
  2008.             ting for this bit. Use the symbolic #defines found in the lite-
  2009.             comm.h file. Generally, this function only has value if you
  2010.             trying to implement some form of hardware handshaking with
  2011.             another device.  The comm_close function will lower both RTS and
  2012.             DTS automatically, if told to do so.
  2013.  
  2014.             Example            Example            Example
  2015.             /* lower the RTS modem control signal */
  2016.                  lc_clrmdm(port, RTS);
  2017.  
  2018.             /* lower both RTS and DTR */
  2019.                  lc_clrmdm(port, (RTS | DTR));
  2020.  
  2021.             RETURN VALUES
  2022.  
  2023.             Returns 0 if the operation was successful, returns -1 otherwise.
  2024.             SEE ALSO
  2025.             comm_close, lc_setmdm, lc_togmdm 
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.                                             32
  2052.  
  2053.  
  2054.  
  2055.  
  2056.        lc_togmdm
  2057.  
  2058.  
  2059.             SUMMARY
  2060.             #include <litecomm.h>
  2061.  
  2062.             int lc_togmdm(port, newset)
  2063.             unsigned port;
  2064.             unsigned newset;
  2065.             DESCRIPTION
  2066.  
  2067.             Companion to setmdm function. Inverts (flip-flops) the modem
  2068.             control signals RTS or DTR or both. Because of the need to have
  2069.             OUT2 set for interrupt support, the function always provides the
  2070.             correct setting for this bit. Use the symbolic #defines found in
  2071.             the litecomm.h file.  This function may have value if you are
  2072.             trying to implement hardware handshaking.
  2073.  
  2074.             Example            Example            Example
  2075.             /* 
  2076.             ** change the RTS modem control signal to its other
  2077.  
  2078.             ** state (e.g. if raised, lower, and if lowered, raise
  2079.             */
  2080.                  lc_togmdm(port, RTS);
  2081.  
  2082.  
  2083.             RETURN VALUES
  2084.             Returns 0 if the operation was successful, returns -1 otherwise.
  2085.             SEE ALSO
  2086.             lc_setmdm, lc_clrmdm 
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.                                             33
  2114.  
  2115.  
  2116.  
  2117.  
  2118.        lc_xoff 
  2119.  
  2120.  
  2121.             SUMMARY
  2122.             #include <litecomm.h>
  2123.  
  2124.             int lc_xoff(port, flag)
  2125.             unsigned port;
  2126.             int flag; 
  2127.             DESCRIPTION
  2128.  
  2129.             If flag is non-zero, the function enables automatic software flow
  2130.             control function. If flag is zero (the default setting),
  2131.             automatic flow control is disabled.
  2132.  
  2133.             When enabled, the LiteComm kernel will automatically transmit the
  2134.             OFF character when the input buffer is approximately 2/3 full and
  2135.             will automatically recognize an OFF character sent by the other
  2136.             device. If the other device transmits an OFF character, the ker-
  2137.             nel will refuse to send any characters until the condition is
  2138.             cleared by receipt of the ON character or by disabling software
  2139.             flow control altogether.  
  2140.             The recognition functionality is implimented in the kernel.  As a
  2141.             result, the transmit buffer will continue to accept input from
  2142.             your program until the buffer fills completely, even though the
  2143.             information will not be sent.  Once the matching ON character is
  2144.             received, the contents of the transmit buffer will be sent
  2145.             rapidly to the other device.  It is possible that the rate with
  2146.             which characters are sent when this occurs may cause problems for
  2147.             the other device, depending on its ability to handle the data
  2148.             flow.
  2149.  
  2150.             If you intended to implement a protocol that might include the ON
  2151.             or OFF characters, be sure to disable the automatic flow control.
  2152.             Failure to do so may result in a system hang.
  2153.  
  2154.             By default, software flow control uses the XON-XOFF flow control
  2155.             characters. You may change the characters to suit your applica-
  2156.             tion by using the lc_setxon and lc_setxoff functions.
  2157.             RETURN VALUES
  2158.  
  2159.             Returns 0 if the operation was successful, returns -1 otherwise.
  2160.             SEE ALSO
  2161.             lc_gotxoff, lc_putxoff, lc_setxon, lc_setxoff
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.                                             34
  2176.  
  2177.  
  2178.  
  2179.  
  2180.        lc_gotxoff
  2181.  
  2182.  
  2183.             SUMMARY
  2184.             #include <litecomm.h>
  2185.  
  2186.             int lc_gotxoff(port)
  2187.             unsigned port;
  2188.             DESCRIPTION
  2189.             If the OFF character has been received, this function will return
  2190.             a non-zero value. A zero is returned if the OFF character is
  2191.             never received, or if the ON character is detected.
  2192.  
  2193.             Note:            Note:            Note:Unlike older versions of LiteComm, lc_gotxoff is now useful
  2194.             only for information. It does not alter the way in which software
  2195.             flow control operates.
  2196.             RETURN VALUES
  2197.             Returns a nonzero value if the OFF character was detected, zero
  2198.             if an OFF character was not detected, or if the ON character is
  2199.             detected. Will return -1 in the case of an error.
  2200.  
  2201.             SEE ALSO
  2202.             lc_xoff, lc_putxoff, lc_setxon, lc_setxoff
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.                                             35
  2238.  
  2239.  
  2240.  
  2241.  
  2242.        lc_putxoff
  2243.  
  2244.  
  2245.             SUMMARY
  2246.             #include <litecomm.h>
  2247.  
  2248.             int lc_putxoff(port)
  2249.             unsigned port;
  2250.             DESCRIPTION
  2251.             See below for the values returned. If the LiteComm kernel has
  2252.             sent the OFF character.
  2253.  
  2254.             Note:            Note:            Note:Unlike older versions of LiteComm, this function provides
  2255.             information only. Use of the function has no effect upon software
  2256.             flow control. 
  2257.             RETURN VALUES
  2258.             Returns a nonzero value if an OFF character was sent to the other
  2259.             device, zero if an OFF was not sent, or if the ON character has
  2260.             been sent. Will return -1 in the case of an error.
  2261.  
  2262.             SEE ALSO
  2263.             lc_xoff, lc_putxoff, lc_setxon, lc_setxoff
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.                                             36
  2300.  
  2301.  
  2302.  
  2303.  
  2304.        lc_setxon, lc_setxoff
  2305.  
  2306.  
  2307.             SUMMARY
  2308.             #include "litecomm.h"
  2309.  
  2310.             int lc_setxon(port, xonchar);
  2311.             int lc_setxoff(port, xoffchar);
  2312.             unsigned port;
  2313.             unsigned char xonchar;
  2314.  
  2315.             unsigned char xoff char;
  2316.             DESCRIPTION
  2317.             These functions are part of the software flow control functonal-
  2318.             ity of LiteComm. By default, LiteComm's software flow control
  2319.             uses the XON-XOFF character scheme. If your application has dif-
  2320.             ferent requirements, use the lc_setxon function to change the ON
  2321.             character, lc_setxoff to set the OFF character.
  2322.             RETURN VALUES
  2323.  
  2324.             Both functions return a -1 if an error occurs. Both return a
  2325.             value of zero (0) if there is no error.
  2326.             SEE ALSO
  2327.             lc_xoff, lc_gotxoff, lc_putxoff
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.                                             37
  2362.  
  2363.  
  2364.  
  2365.  
  2366.        lc_sethwflow
  2367.  
  2368.  
  2369.             SUMMARY
  2370.             #include "litecomm.h"
  2371.  
  2372.             int lc_sethwflow(port, flowtype)
  2373.             unsigned port;
  2374.             unsigned char flowtype;
  2375.             DESCRIPTION
  2376.  
  2377.             This function specifies the type of hardware flow control to use
  2378.             and activates hardware flow control. The point at which hardware
  2379.             flow control is activated is the same as for software flow con-
  2380.             trol.
  2381.  
  2382.             You have complete control over which hardware signals are used
  2383.             for flow control. For output (from the port) control specify ei-
  2384.             ther USEDSR or USECTS. For input (to the port) control, specify
  2385.             either USEDTR or USERTS. Since most hardware flow control schemes
  2386.             employ both input and output flow control, you should OR the re-
  2387.             quired values together, as shown in the example. Hardware flow
  2388.             control remains in effect until you issue the lc_clearhwflow
  2389.             function.
  2390.  
  2391.  
  2392.             Note:            Note:            Note:The flow control scheme assumes that the input flow control
  2393.             signal (RTS or DTR) have been set to the correct starting value
  2394.             by the program. Thereafter, LiteComm flow control will manage the
  2395.             signals.
  2396.  
  2397.  
  2398.             Example            Example            Example
  2399.  
  2400.             /* Use RTS-CTS flow control */
  2401.             if  lc_sethwflow(port, (USECTS | USERTS))
  2402.                  puts("Error setting flow control");
  2403.  
  2404.  
  2405.             RETURN VALUES
  2406.             The function returns a value of zero (0) if successful. If an
  2407.             error occurs, the function returns -1.
  2408.             SEE ALSO
  2409.             lc_xoff, lc_clearhwflow, lc_puthwstop, lc_gothwstop
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.                                             38
  2424.  
  2425.  
  2426.  
  2427.  
  2428.        lc_clearhwflow
  2429.  
  2430.  
  2431.             SUMMARY
  2432.             #include "litecomm.h"
  2433.  
  2434.             int lc_clearhwflow(port)
  2435.             unsigned port;
  2436.             DESCRIPTION
  2437.             Immediately deactivates hardware flow control. Any untransmitted
  2438.             characters will be sent as rapidly as possible.
  2439.  
  2440.             RETURN VALUES
  2441.             If successful, returns a value of zero (0). Retuirns -1 if an
  2442.             error occurs.
  2443.             SEE ALSO
  2444.  
  2445.             lc_sethwflow, lc_puthwstop, lc_gothwstop
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.                                             39
  2486.  
  2487.  
  2488.  
  2489.  
  2490.        lc_puthwstop
  2491.  
  2492.  
  2493.             SUMMARY
  2494.             #include "litecomm.h"
  2495.  
  2496.             int lc_puthwstop(port)
  2497.             unsigned port;
  2498.             DESCRIPTION
  2499.             Indicates whether or not LiteComm has instructed the remote de-
  2500.             vice to stop transmitting.
  2501.  
  2502.             RETURN VALUES
  2503.             If an error occurs, returns a value of -1. If input flow control
  2504.             has not been asserted, returns a value of zero (0). If input flow
  2505.             control has been asserted, returns a positive, non-zero value;
  2506.             SEE ALSO
  2507.  
  2508.             lc_sethwflow, lc_gothwflow
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.                                             40
  2548.  
  2549.  
  2550.  
  2551.  
  2552.        lc_gothwstop
  2553.  
  2554.  
  2555.             SUMMARY
  2556.             #include "litecomm.h"
  2557.  
  2558.             int lc_gothwstop(port)
  2559.             unsigned port;
  2560.             DESCRIPTION
  2561.             Indicates whether or not LiteComm has been instructed by the re-
  2562.             mote device to stop transmitting.
  2563.  
  2564.             RETURN VALUES
  2565.             If an error occurs, returns a value of -1. If output flow control
  2566.             has not been asserted, returns a value of zero (0). If output
  2567.             flow control has been asserted by the remote device, returns a
  2568.             positive, non-zero value;
  2569.             SEE ALSO
  2570.  
  2571.             lc_sethwflow, lc_puthwflow
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.                                             41
  2610.  
  2611.  
  2612.  
  2613.  
  2614.        lc_get
  2615.  
  2616.  
  2617.             SUMMARY
  2618.             #include <litecomm.h>
  2619.  
  2620.             int lc_get(port)
  2621.             unsigned port;
  2622.             DESCRIPTION
  2623.             Read a character from the serial port's input buffer. Discard
  2624.             (ignore) the matching status value
  2625.  
  2626.  
  2627.  
  2628.             Example            Example            Example
  2629.             if ((ch = lc_get(port)) != -1)
  2630.             /* any chars? */
  2631.                  ch &= 0x7f;         /* mask parity */
  2632.  
  2633.  
  2634.             RETURN VALUES
  2635.             Returns the next available character in the input buffer for the
  2636.             port. If you specified other than NO PARITY when you opened the
  2637.             port, you may have to mask (make zero) the parity bit before you
  2638.             use the character. Returns -1 if the port is not active, or if
  2639.             there are not characters in the port's buffer.
  2640.  
  2641.             SEE ALSO
  2642.             lc_getstat, wait, purge
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.                                             42
  2672.  
  2673.  
  2674.  
  2675.  
  2676.        lc_getstat
  2677.  
  2678.  
  2679.             SUMMARY
  2680.             #include "litecomm.h"
  2681.  
  2682.             int lc_getstat(port, ch, status);
  2683.             unsigned port;
  2684.             unsigned char *ch;
  2685.             unsigned char *status;
  2686.  
  2687.             DESCRIPTION
  2688.             This function retrieves the next character and its corresponding
  2689.             error status from the LiteComm buffers, if there are characters
  2690.             available. The status that is returned is the value of the error
  2691.             status register at the time the character was received. For more
  2692.             information about the error status see the lc_estat function.
  2693.             Note:            Note:            Note:The variables for ch and status must both be pointers.
  2694.  
  2695.             RETURN VALUES
  2696.             If there are characters available and no other errors occur, the
  2697.             function will return a value of zero (0). If there are no other
  2698.             characters, or if some other error occurs, the function returns a
  2699.             value of -1.
  2700.             SEE ALSO
  2701.             lc_get, lc_estat, wait, purge
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.                                             43
  2734.  
  2735.  
  2736.  
  2737.  
  2738.        wait
  2739.  
  2740.  
  2741.             SUMMARY
  2742.             #include "litecomm.h"
  2743.  
  2744.             int wait(port, secs, sig_to_check);
  2745.             unsigned port;
  2746.             int secs;
  2747.             unsigned char sig_to_check;
  2748.  
  2749.             DESCRIPTION
  2750.             The wait function waits for secs seconds for input from the des-
  2751.             ignated port before returning. Optionally, wait will also monitor
  2752.             one or more of the modem status signals and return if the signal
  2753.             drops.
  2754.  
  2755.             Secs must be greater than zero. If you do not want wait to moni-
  2756.             tor a modem status signal, specify zero (0) as sig_to_check. To
  2757.             specify a signal, use the constants, such as DCD, found in lite-
  2758.             comm.h.
  2759.  
  2760.  
  2761.             Note:            Note:            Note:Valid signal values are CTS, DCD, DSR, and RI.
  2762.             RETURN VALUES
  2763.             If a character is retrieved within the time allowed, the function
  2764.             returns the character. If a character is not available in the
  2765.             specified time, if the specified signal is lost, or if some other
  2766.             error occurs, the function returns a value of -1.
  2767.  
  2768.             SEE ALSO
  2769.             lc_get, lc_getstat
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.                                             44
  2796.  
  2797.  
  2798.  
  2799.  
  2800.        purge
  2801.  
  2802.  
  2803.             SUMMARY
  2804.             #include "litecomm.h";
  2805.  
  2806.             void purge(port);
  2807.             unsigned port;
  2808.             DESCRIPTION
  2809.             The purge function discards any characters received until there
  2810.             are no more incoming characters for a period of 1 second.
  2811.  
  2812.             RETURN VALUES
  2813.             This function does not return any value;
  2814.             SEE ALSO
  2815.  
  2816.             wait
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.                                             45
  2858.  
  2859.  
  2860.  
  2861.  
  2862.        lc_peek
  2863.  
  2864.  
  2865.             SUMMARY
  2866.             #include <litecomm.h>
  2867.  
  2868.             int lc_peek(port)
  2869.             unsigned port;
  2870.             DESCRIPTION
  2871.             Look at the next character in the serial port's input buffer. Do
  2872.             not remove the character from the buffer.
  2873.  
  2874.             RETURN VALUES
  2875.             Returns the next available character in the input buffer for the
  2876.             port, but does not remove the character from the buffer. This
  2877.             allows the application to look-ahead by one character in a
  2878.             nondestructive fashion. See additional comments under lc_get re-
  2879.             garding parity. Returns -1 if the port is not active, or if there
  2880.             are no characters in the port's buffer.
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.                                             46
  2920.  
  2921.  
  2922.  
  2923.  
  2924.        lc_put
  2925.  
  2926.  
  2927.             SUMMARY
  2928.             #include <litecomm.h>
  2929.  
  2930.             int lc_put(port,ch)
  2931.             unsigned port;
  2932.             char ch;
  2933.             DESCRIPTION
  2934.  
  2935.             Place a character into the serial port's output buffer.
  2936.             RETURN VALUES
  2937.             Returns 0 if successful. Note that this does not guarantee that
  2938.             the character has been sent, only that no errors were detected,
  2939.             and that there was room in the transmit buffer for the character.
  2940.             Characters are sent from the transmit buffer when the system has
  2941.             time to send them, assuming all conditions for transmission are
  2942.             satisified.  Returns -1 if the port is not active, or if there no
  2943.             room in the port's buffer.
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.                                             47
  2982.  
  2983.  
  2984.  
  2985.  
  2986.        lc_gets
  2987.  
  2988.  
  2989.             SUMMARY
  2990.             #include <litecomm.h>
  2991.  
  2992.             int lc_gets(port, buff, cnt)
  2993.             unsigned port;
  2994.             char *buff;
  2995.             int cnt;
  2996.  
  2997.             DESCRIPTION
  2998.             Read a stream of, at most, cnt characters from the serial port's
  2999.             input buffer into the buff location. Ignore and discard any sta-
  3000.             tus information. This function is not sensitive to the NULL
  3001.             character. See lc_get for additional information.
  3002.  
  3003.  
  3004.  
  3005.             Example            Example            Example
  3006.             char * j;
  3007.             int k;
  3008.             int wrk;
  3009.  
  3010.             j = buff;           /* point to top of our buffer */
  3011.  
  3012.             k = sizeof(buff);        /* set chars needed to fill */
  3013.             do
  3014.             {
  3015.                  wrk = lc_gets(port, j, k);
  3016.                  if (wrk != -1) /* got something ? */
  3017.                  {
  3018.                       j += wrk; /* bump buffer pointer */
  3019.                       k -= wrk; /* decrement  chars req'd */
  3020.  
  3021.                  }
  3022.             } until (k <= 0);
  3023.  
  3024.             RETURN VALUES
  3025.  
  3026.             Returns the count of characters transferred into buffer, or -1 if
  3027.             an error occurs. 
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.                                             48
  3044.  
  3045.  
  3046.  
  3047.  
  3048.        lc_puts
  3049.  
  3050.  
  3051.             SUMMARY
  3052.             #include <litecomm.h>
  3053.  
  3054.             int lc_puts(port, buff, cnt)
  3055.             unsigned port;
  3056.             char *buff;
  3057.             int cnt;
  3058.  
  3059.             DESCRIPTION
  3060.             Place a stream of, at most,                                                                                 cnt characters into the serial port's
  3061.             output buffer. Any required parity will be supplied by the serial
  3062.             port itself.
  3063.  
  3064.  
  3065.  
  3066.             Example            Example            Example
  3067.             char * j
  3068.             int j;
  3069.             int sent;
  3070.                  j = buff;
  3071.                  k = sizeof(buff)
  3072.  
  3073.                  do
  3074.                  {
  3075.                       sent = lc_puts(port, j, k);
  3076.                       if (sent > 0)
  3077.                       {
  3078.                            j += sent;
  3079.                            k -= sent;
  3080.                       }
  3081.  
  3082.                  } until (k <= 0);
  3083.  
  3084.             RETURN VALUES
  3085.  
  3086.             Returns the number of characters placed into the buffer. Note
  3087.             that this does not guarantee that the characters have been sent.
  3088.             The number of characters transferred into the output buffer may
  3089.             be less than the actual request. Returns 0 if any error occurs,
  3090.             or if there is no room in the port's buffer.
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.                                             49
  3106.  
  3107.  
  3108.  
  3109.  
  3110.        lc_flush
  3111.  
  3112.  
  3113.             SUMMARY
  3114.             #include <litecomm.h>
  3115.  
  3116.             int lc_tflush(port)
  3117.             int lc_rflush(port)
  3118.             int lc_flshtrue(port, ch)
  3119.             int lc_nflush(port, cnt)
  3120.  
  3121.             unsigned port;
  3122.             char ch;
  3123.             int cnt;
  3124.             DESCRIPTION
  3125.  
  3126.             The lc_?flush functions remove characters from the specified
  3127.             buffer and discard them; untransmitted characters in the transmit
  3128.             buffer are NEVER sent; unprocessed characters in the receive
  3129.             buffer are lost.  Do not try to use the lc_tflush to force char-
  3130.             acters to be transmitted.  The tflush function unconditionally
  3131.             empties the transmit buffer, discarding any unsent characters.
  3132.                lc_tflush empties the port's transmit buffer immediately.
  3133.                lc_rflush empties the port's receive and status buffers im-
  3134.                mediately.
  3135.  
  3136.                lc_flshtrue will continually dispose of received characters
  3137.                until the function finds the character ch. Use caution with
  3138.                this one since it does not detect port number errors, and may
  3139.                appear to seize the system.
  3140.                lc_nflush flushes, at most, cnt characters from the port's re-
  3141.                ceive and status buffers.
  3142.             RETURN VALUES
  3143.             lc_flshtrue returns no values. lc_tflush and lc_rflush return 0
  3144.             if successful and -1 if an error occurs. lc_nflush returns the
  3145.             number of characters flushed from the receive buffer or 0 when
  3146.             there are no characters to flush, or when an error occurs.
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.                                             50
  3168.  
  3169.  
  3170.  
  3171.  
  3172.        lc_sbrk
  3173.  
  3174.  
  3175.             SUMMARY
  3176.             #include <litecomm.h>
  3177.  
  3178.             int lc_sbrk(port)
  3179.             lc_gotbrk(port)
  3180.             unsigned port;
  3181.             DESCRIPTION
  3182.  
  3183.             lc_sbrk() generates a BREAK signal using a particular character-
  3184.             istic of the 8250 UART family to generate an accurate BREAK at
  3185.             any baud rate.  BREAKs generated in this manner are timed based
  3186.             upon the baud rate at which the 8250 is currently initialized.
  3187.             This function may or may not work correctly with other than the
  3188.             actual 8250 UART or its relatives.
  3189.             RETURN VALUES
  3190.             lc_gotbrk returns a nonzero value if a break signal has been re-
  3191.             ceived on the specified port.  It returns zero otherwise.
  3192.             lc_sbrk Returns 0 if successful. Returns -1 if the port is not
  3193.             active.
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.                                             51
  3230.  
  3231.  
  3232.  
  3233.  
  3234.        newtimer_s
  3235.  
  3236.  
  3237.             SUMMARY
  3238.             include "lctime.h";
  3239.  
  3240.             void newtimer_s(et, sec);
  3241.             EVENT *et;
  3242.             unsigned sec;
  3243.  
  3244.  
  3245.             int check_timer(et);
  3246.             EVENT ev;
  3247.             DESCRIPTION
  3248.             The newtimer_s function creates an 'event timer' that will expire
  3249.             in sec seconds.  This function relies upon the calculation of an
  3250.             absolute time value and does not tie into any system interrupt,
  3251.             permitting as many independent timeout timers as required by your
  3252.             application.
  3253.  
  3254.             The check_timer function examines the contents of an event timer
  3255.             created by newtimer_s with respect to the current date and time,
  3256.             and indicates whether the timer has expired.
  3257.             Do not attempt to use check_timer against a variable that was not
  3258.             set by newtimer_s.  If you do so, the results are unpredictable
  3259.             and may result in a seeming system hang.
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.                                             52
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.             Example            Example            Example
  3299.             EVENT cdtimer;
  3300.  
  3301.  
  3302.             newtimer_s(&cdtimer, 30); /* 30 second timer */
  3303.             while( ! check_timer(cdtimer))
  3304.                  if (check_for_call(port) > 0)
  3305.                  {
  3306.                       cprintf("Incoming call\r\n");
  3307.                       return(1);
  3308.  
  3309.                  }
  3310.                  cprintf("No calls in 30 seconds\r\n");
  3311.             return(0);
  3312.  
  3313.  
  3314.             RETURN VALUES
  3315.             The newtimer_s function returns no value but initializes a
  3316.             structure that represents a point in time sec seconds from the
  3317.             time that newtimer_s was called. The check_timer function returns
  3318.             a nonzero value if the specified event timer has expired, a value
  3319.             of zero otherwise.
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.                                             53
  3354.  
  3355.  
  3356.  
  3357.  
  3358.        BBS SUPPORT FUNCTIONS
  3359.  
  3360.  
  3361.        INTRODUCTION
  3362.             In this chapter, we discuss a set of utility functions that were
  3363.             originally developed as a part of a BBS package with one of our
  3364.             registered users.  Not only are they useful, in and of them-
  3365.             selves, but they also act as examples of using the LiteComm
  3366.             ToolBox in situations that puzzle some users.
  3367.  
  3368.             ADDITIONAL NOTES
  3369.             The use of any of the functions that follow in this section re-
  3370.             quire that you define, in your code, three modem setup strings
  3371.             with the names MODEMSET0, MODEMSET1, and MODEMSET2, and must be
  3372.             pointers to characters.  In addition, they must be defined as
  3373.             global variables, and must be public (i.e., not static). Below,
  3374.             we show one way to do this.
  3375.  
  3376.  
  3377.  
  3378.             Example            Example            Example
  3379.             char istrng0[] = "ATZ\r";
  3380.             char istrng1] = "ATT E0 V0 X1 M1\r";
  3381.             char istrng2[] = "ATS0=1\r";
  3382.             char *MODEMSET0;
  3383.             char *MODEMSET1;
  3384.             char *MODEMSET2;
  3385.  
  3386.             void main(void)
  3387.             {
  3388.                  ...
  3389.                  MODEMSET0 = &istrng0[0];
  3390.                  MODEMSET1 = &istrng1[0];
  3391.                  MODEMSET2 = &istrng2[0];
  3392.                  ...
  3393.  
  3394.             }
  3395.  
  3396.             Experienced C programmers will readily recognize that this is not
  3397.             necessarily the best approach.  But it does serve to illustrate
  3398.             clearly the ideas involved.  Be sure to define  MODEMSET0, 1, and
  3399.             2 as pointers to characters as shown above, and NOT as arrays.
  3400.             It is a fine destinction in C, but an important one.
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.                                             54
  3416.  
  3417.  
  3418.  
  3419.  
  3420.        check_for_call
  3421.  
  3422.  
  3423.             SUMMARY
  3424.             include "lcbbs.h";
  3425.  
  3426.             int check_for_call(port)
  3427.             unsigned port;
  3428.             DESCRIPTION
  3429.             This function checks the status of the specified port to deter-
  3430.             mine whether (1) there is an incoming call and (2) waits for up
  3431.             to 30 seconds for carrier to be established with the caller if
  3432.             the phone rang.  Please note that this function relies upon, in
  3433.             part, the HAYES command set.  Use with other than HAYES- compat-
  3434.             ible modems may result in unexpected hangs or other, unpredict-
  3435.             able results.  The function assumes that the modem parameters
  3436.             have been set in the manner described in the reset_modem func-
  3437.             tion.
  3438.  
  3439.             In the event that a wrong number call is received, check_for_call
  3440.             will automatically disconnect by lowering  the DTR(Data Terminal
  3441.             Ready) signal momentarily, then automatically call the reset_mo-
  3442.             dem function.  See the notes at the beginning of this chapter,
  3443.             and in the discussion of the reset_modem function.  This method
  3444.             of disconnecting, while absolute, will only work correctly if you
  3445.             HAVE NOT set your modem to ignore the DTR signals, as is possible
  3446.             with some modems.  Please consult your modem's documentation for
  3447.             additional detail.
  3448.             RETURN VALUES
  3449.             If the phone was not ringing, the function returns a value of
  3450.             zero.  If detects a ring was detected, but does not detect
  3451.             carrier within 30 seconds, the function will return a value of -1
  3452.             after forcing a disconnect and resetting the modem.  Otherwise,
  3453.             the function returns the numeric result code, in integer form.
  3454.             It is the programmer's responsibility to interpret and act upon
  3455.             the result code.  For the function to work properly, the modem
  3456.             must be set to return numeric result codes rather than word re-
  3457.             sult codes.
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.                                             55
  3478.  
  3479.  
  3480.  
  3481.  
  3482.        get_modem_reply
  3483.  
  3484.  
  3485.             SUMMARY
  3486.             include "lcbbs.h"
  3487.  
  3488.             int get_modem_reply(port)
  3489.             unsigned port;
  3490.             DESCRIPTION
  3491.             The get_modem_reply function is intended for use after a command
  3492.             has been issued to a HAYES compatible modem.  To operate proper-
  3493.             ly, the modem must be set to return numeric responses rather than
  3494.             word responses.  The function returns to the caller when one of
  3495.             the following occurs:
  3496.  
  3497.                No response from the modem within 1 second.
  3498.                More than 2 response characters received before a <CR> is de-
  3499.                tected.
  3500.                A <CR> is received from the modem.  
  3501.  
  3502.             Due to the internal logic employed, the programmer should call
  3503.             this function, or purge the receive buffer, after each command
  3504.             sent to the modem.  Failure to do so will result in improper in-
  3505.             terpretation of the result codes returned.
  3506.             RETURN VALUES
  3507.             Returns a value of -1 if there is no response from the modem
  3508.             within 1 second.  Otherwise returns the integer result code.  If
  3509.             the modem has not been set to return numeric result codes, the
  3510.             results are unpredictable.
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.                                             56
  3540.  
  3541.  
  3542.  
  3543.  
  3544.        reset_modem
  3545.  
  3546.  
  3547.             SUMMARY
  3548.             include "lcbbs.h"
  3549.  
  3550.             int reset_modem(port)
  3551.             unsigned port;
  3552.             DESCRIPTION
  3553.             The reset_modem function initializes the modem to a known state,
  3554.             suitable for use with the other bbs functions, and based upon a
  3555.             set of initialization strings provided by the user's program.
  3556.             See the notes at the beginning of this chapter for additional
  3557.             information regarding the way that this must be done. 
  3558.  
  3559.             Because the modem-related functions in this section make certain
  3560.             assumptions about the modem, your initialization strings should
  3561.             include, at a minimum, the following:
  3562.                No command echo
  3563.                Detect carrier
  3564.  
  3565.                Return numeric result codes
  3566.                Answer the phone on the first ring (if you need to use the
  3567.                check_for_call function)
  3568.             A sample set of initialization strings is shown at the start of
  3569.             this chapter. If you require any additional information on these
  3570.             or related options, please consult your modem's documentation.
  3571.             RETURN VALUES
  3572.  
  3573.             The reset_modem function returns the same result code as those
  3574.             specified for get_modem_reply.
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.                                             57
  3602.  
  3603.  
  3604.  
  3605.  
  3606.        disconnect
  3607.  
  3608.  
  3609.             SUMMARY
  3610.             include "lcbbs.h"
  3611.  
  3612.             void disconnect(port)
  3613.             unsigned port;
  3614.             DESCRIPTION
  3615.             The disconnect forcibly disconnects the modem from the telephone
  3616.             line by lowering the DTR signal momentarily.  You must be certain
  3617.             that your modem IS NOT set to ignore the DTR signal for the
  3618.             function to work properly.
  3619.  
  3620.             RETURN VALUES
  3621.             Disconnect returns no values.
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.                                             58
  3664.  
  3665.  
  3666.  
  3667.  
  3668.        HAYES MODEM FUNCTIONS
  3669.  
  3670.  
  3671.             Note:            Note:            Note:When using the following functions, you must include the
  3672.             file litehcm.h in your program. litehcm.h automatically includes
  3673.             the litecomm.h header file.
  3674.  
  3675.             FUNCTIONS
  3676.                  lch_codeset
  3677.                  lch_dial
  3678.                  lch_fduplex
  3679.                  lch_hduplex
  3680.  
  3681.                  lch_greg
  3682.                  lch_sreg
  3683.                  lch_offcarr
  3684.                  lch_oncarr
  3685.  
  3686.                  lch_offecho
  3687.                  lch_onecho
  3688.                  lch_hook
  3689.                  lch_redo
  3690.  
  3691.                  lch_numres
  3692.                  lch_wrdres
  3693.                  lch_codesoff
  3694.                  lch_codeson
  3695.  
  3696.                  lch_pulse
  3697.                  lch_tone
  3698.                  lch_speaker
  3699.                  _retset
  3700.                  _rettype
  3701.  
  3702.             SUMMARY
  3703.             #include <litehcm.h>
  3704.             int lch_codeset(port,mode)
  3705.             int lch_dial(port,dstr)
  3706.  
  3707.             int lch_fduplex(port)
  3708.             int lch_hduplex(port)
  3709.             int lch_greg(port,reg)
  3710.             int lch_sreg(port,reg,value)
  3711.  
  3712.             int lch_offcarr(port)
  3713.             int lch_oncarr(port)
  3714.             int lch_offecho(port)
  3715.             int lch_onecho(port)
  3716.  
  3717.             int lch_hook(port,hmode)
  3718.             int lch_redo(port)
  3719.             int lch_numres(port)
  3720.             int lch_wrdres(port)
  3721.  
  3722.             int lch_codesoff(port)
  3723.             int lch_codeson(port)
  3724.  
  3725.                                             59
  3726.  
  3727.  
  3728.  
  3729.  
  3730.             int lch_pulse(port)
  3731.             int lch_tone(port)
  3732.             int lch_speaker(port,spkmode)
  3733.             int _retset()
  3734.  
  3735.             int _rettype()
  3736.             unsigned port;
  3737.             unsigned mode;
  3738.             char *dstr;
  3739.  
  3740.             unsigned reg;
  3741.             int value;
  3742.             unsigned hmode;
  3743.             unsigned spkmode; 
  3744.  
  3745.             DESCRIPTION
  3746.             The values to be used with mode, hmode, and spkmode are defined
  3747.             symbolically in the #include file, litehcm.h.
  3748.             The lch_codeset                lch_codeset                lch_codeset function allows you to change the set of codes
  3749.             returned by the modem when an action is specified.
  3750.  
  3751.  
  3752.             lch_dial            lch_dial            lch_dial instructs the modem to dial the number contained in
  3753.             dstr. Do not include the dialing (ATD) prefix, or the trailing
  3754.             <\r>. These are provided by the function. You may include non-
  3755.             numeric characters that are acceptable to your modem, since the
  3756.             function does not check the contents of dstr. The dialing is in
  3757.             the last known dialing mode, either pulse or tone. If you use the
  3758.             lch_pulse or lch_tone functions, then dialing will be done in the
  3759.             mode that was last correctly enabled. If you have not exercised
  3760.             these functions, then dialing occurs in the modems default or
  3761.             power-up mode.
  3762.  
  3763.             The lch_hduplex                lch_hduplex                lch_hduplex and lch_fduplex                                 lch_fduplex                                 lch_fduplex functions place the modem into
  3764.             local echo and remote echo modes respectively.
  3765.  
  3766.  
  3767.             The lch_greg                lch_greg                lch_greg function requests that the modem report the current
  3768.             value of S-register reg. Reg must be in the range 0 to 13. Use
  3769.             the lc_gets, or similar function, to retrieve the modem's re-
  3770.             sponse. Specifying a register outside the 0 to 13 range will
  3771.             cause a return of -1.
  3772.  
  3773.             lch_sreg            lch_sreg            lch_sreg is the companion to lch_greg, with the same restric-
  3774.             tions. Sets the S-register reg to the value contained in value.
  3775.             If value contains -1, then the register is reset to its default
  3776.             (power-up) value. The function checks the value to be certain
  3777.             that it is within the limits specified for the particular regis-
  3778.             ter, and returns a value of -1 if the value is outside the
  3779.             predefined limits.
  3780.  
  3781.             lch_offcarr            lch_offcarr            lch_offcarr enables modem carrier detect, but disables the mo-
  3782.             dem's carrier signal. The lch_oncarr companion enables both car-
  3783.             rier detect and the modem's carrier signal. When lch_offcarr is
  3784.             used the modem will receive data but will be unable to send data.
  3785.  
  3786.  
  3787.                                             60
  3788.  
  3789.  
  3790.  
  3791.  
  3792.             The lch_offecho                lch_offecho                lch_offecho and lch_onecho                                lch_onecho                                lch_onecho functions determine whether com-
  3793.             mands sent to the modem are echoed back to the sending program.
  3794.             With echo turned off, the modem will continue to accept commands,
  3795.             but will not try to redisplay the command's characters.
  3796.  
  3797.             lch_hook            lch_hook            lch_hook allows you to control the status of the modem's tele-
  3798.             phone line connection. See your modem's documentation and the
  3799.             include file for additional information.
  3800.  
  3801.  
  3802.             The lch_redo                lch_redo                lch_redo function instructs the modem to repeat the last
  3803.             command sequence executed. Generally, this function is of great-
  3804.             est value in redialing numbers that are busy, although its use is
  3805.             not restricted to that.
  3806.  
  3807.             The way in which your modem responds to commands is determined,
  3808.             in part, by the lch_wrdres                            lch_wrdres                            lch_wrdres and lch_numres                                           lch_numres                                           lch_numres functions. If you call
  3809.             lch_wrdres, then modem responses use the English language re-
  3810.             sponse codes, e.g,. CONNECT or OK. Calling lch_numres instructs
  3811.             the modem to respond with code numbers only from the currently
  3812.             selected response set, see the lch_codeset function.
  3813.  
  3814.  
  3815.             You may use the functions lch_codeson                                      lch_codeson                                      lch_codeson and lch_codesoff                                                      lch_codesoff                                                      lch_codesoff to specify
  3816.             whether you want your modem to send back response codes when it
  3817.             receives a command string. In a sense, these act as companions to
  3818.             the lch_xxxecho functions above.
  3819.  
  3820.             Use the lch_speaker                    lch_speaker                    lch_speaker function to control the modem's internal
  3821.             speaker, if it has one. See litehcm.h for the applicable codes.
  3822.  
  3823.  
  3824.             The _retset                _retset                _retset and _rettype                            _rettype                            _rettype functions return, respectively, the last
  3825.             known command set (lch_codeset) and last known result type
  3826.             (lch_wrdres, lch_numres). These functions (_retset, _rettype) are
  3827.             only of value when used with the companion functions.
  3828.  
  3829.             GENERAL REMARKS
  3830.             Several considerations are in order if you intend to use the
  3831.             Hayes ToolBox functions.
  3832.  
  3833.  
  3834.             You are responsible for checking the return codes from the modem
  3835.             once you have given modem a command. To make the task easier, we
  3836.             suggest that you turn OFF command echo. Then you won't have to
  3837.             worry about separating commands from responses. Finally turn ON
  3838.             numeric responses to make the interpretation of result codes
  3839.             easier and faster.
  3840.  
  3841.             Note:            Note:            Note:Be sure that you allow  adequate time between commands for
  3842.             the modem to process the command and respond. Failure to observe
  3843.             this rule may result in commands being misinterpreted or "lost."
  3844.             You can monitor the number of characters in the receive buffer to
  3845.             help you with the timing. Or alternatively, check the response
  3846.             after each command. The latter approach is more in line with what
  3847.             we believe to be good programming practice. 
  3848.  
  3849.                                             61
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.             RETURN VALUES
  3856.             All functions return a value of -1 if a port or other error oc-
  3857.             curs, zero otherwise.
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  
  3906.  
  3907.  
  3908.  
  3909.  
  3910.  
  3911.                                             62
  3912.  
  3913.  
  3914.                                           INDEX                                          INDEX                                          INDEX
  3915.  
  3916.             _lc_error, 18                       get_modem_reply, 56, 57
  3917.             _portchg, 12, 19                    handshaking, 7, 8, 9, 10, 18,
  3918.             _retset, 59, 61                     30, 32, 33
  3919.             _rettype, 59, 61                    HAYES, 55, 56, 59, 61
  3920.                                                 HAYES MODEM FUNCTIONS, 59
  3921.             16450, 3, 9
  3922.             16550, 3                            identification, 4, 6
  3923.             8250, 3, 5, 6, 9, 10, 12, 51        INSTALL, 15
  3924.             8259, 11, 12, 13                    INSTALLATION, 15
  3925.                                                 interrupt, 4, 5, 6, 9, 10,
  3926.             Alignment, 10                       11, 12, 13, 14, 16, 19, 20,
  3927.             ASP, 1                              22, 28, 30, 32, 33, 52
  3928.             baud, 5, 6, 7, 11, 14, 20,
  3929.             23, 51                              IRQ, 11, 12, 13, 19
  3930.             BBS SUPPORT FUNCTIONS, 54           ISA, 4
  3931.                                                 ISR, 4, 5
  3932.             BIOS, 12, 14                        lc_clearhwflow, 38, 39
  3933.             BREAK, 5, 8, 51
  3934.             buffer, 20, 25, 29, 34, 42,         lc_clrmdm, 30, 32, 33
  3935.             46, 47, 48, 49, 50, 56, 61          lc_estat, 28, 43
  3936.             buss, 4, 13                         lc_flush, 50
  3937.                                                 lc_get, 42, 43, 44, 46, 48
  3938.             C, 14, 15, 16, 18, 22, 54
  3939.             chain, 13                           lc_gets, 48, 60
  3940.             check_for_call, 17, 55, 57          lc_getstat, 42, 43, 44
  3941.             COM1, 1, 5, 12, 14                  lc_getw, 29
  3942.             COM2, 8, 11, 12, 14                 lc_got, 26, 27
  3943.                                                 lc_gothwstop, 38, 39, 41
  3944.             COM3, 11, 12, 13, 14, 19
  3945.             COM4, 1, 11, 12, 13, 14, 19         lc_gotxoff, 34, 35, 37
  3946.             comm_close, 20, 22, 32              lc_icnt, 25
  3947.             comm_opn, 11, 12, 20, 22, 23,       lc_mstat, 17, 26, 27
  3948.             24, 30                              lc_ocnt, 25
  3949.  
  3950.             comm_setup, 23                      lc_peek, 46
  3951.             control, 3, 4, 5, 7, 8, 9,          lc_put, 47
  3952.             10, 11, 16, 18, 20, 22, 24,         lc_puthwstop, 38, 39, 40
  3953.             30, 32, 33, 34, 35, 36, 37,         lc_puts, 49
  3954.             38, 39, 40, 41, 61
  3955.             debuggers, 14                       lc_putxoff, 34, 35, 36, 37
  3956.             Digiboard, 12                       lc_sbrk, 51
  3957.                                                 lc_setdtr, 30, 31
  3958.             disconnect, 55, 58                  lc_sethwflow, 38, 39, 40, 41
  3959.             divisor, 5
  3960.             DTR, 7, 10, 20, 21, 22, 30,         lc_setmdm, 10, 30, 31, 32, 33
  3961.             31, 32, 33, 38, 55, 58              lc_setrts, 30, 31
  3962.             echo, 57, 60, 61                    lc_setxoff, 34, 35, 36, 37
  3963.                                                 lc_setxon, 34, 35, 36, 37
  3964.             EISA, 4
  3965.             ERROR, 5, 6, 10, 11, 18, 21,        lc_togmdm, 30, 32, 33
  3966.             22, 23, 24, 25, 26, 28, 35,         lc_vport, 24
  3967.             36, 37, 38, 39, 40, 41, 43,         lc_xoff, 34, 35, 36, 37, 38
  3968.             44, 48, 49, 50, 62                  lch_codeset, 59, 60, 61
  3969.             event, 52, 53, 55                   lch_codesoff, 59, 61
  3970.             flow control, 11, 18, 34, 35,
  3971.             36, 37, 38, 39, 40, 41              lch_codeson, 59, 61
  3972.  
  3973.  
  3974.                                           INDEX                                          INDEX                                          INDEX
  3975.  
  3976.             lch_dial, 59, 60                    status, 5, 6, 7, 8, 11, 26,
  3977.             lch_fduplex, 59, 60                 27, 28, 31, 42, 43, 44, 48,
  3978.             lch_greg, 59, 60                    50, 55, 61
  3979.             lch_hduplex, 59, 60                 TSR, 16
  3980.                                                 UART, 3, 9, 12, 51
  3981.             lch_hook, 59, 61                    USECTS, 38
  3982.             lch_numres, 59, 61
  3983.             lch_offcarr, 59, 60                 USEDSR, 38
  3984.             lch_offecho, 59, 61                 USEDTR, 38
  3985.                                                 USERTS, 38
  3986.             lch_onecho, 59, 61                  vector, 4, 11, 12, 13, 19
  3987.             lch_redo, 59, 61
  3988.             lch_speaker, 59, 61                 wait, 42, 43, 44, 45
  3989.             lch_sreg, 59, 60                    warning, 9, 10
  3990.                                                 warranty, 2
  3991.             lch_wrdres, 59, 61                  workarounds, 9
  3992.             length, 7, 20
  3993.             libraries, 15, 16                   Xmodem, 2
  3994.             license, 2                          Xmodem-1K, 2
  3995.                                                 XON-XOFF, 18, 34, 37
  3996.             memory, 4, 9, 10, 12, 20, 22        YModem, 2
  3997.             micro-channel, 4
  3998.             multitasking, 16, 17                ZModem, 2
  3999.             newtimer_s, 52, 53
  4000.             NULL, 24, 48
  4001.  
  4002.             open, 8, 9, 10, 11, 12, 14,
  4003.             20, 21, 22, 25, 26, 28
  4004.             OUT2, 7, 30, 32, 33
  4005.             parity, 7, 10, 20, 23, 28,
  4006.             42, 46, 49
  4007.             PC, 3, 4, 9, 10, 11, 12, 13
  4008.  
  4009.             port, 3, 4, 5, 6, 7, 8, 9,
  4010.             10, 11, 12, 13, 14, 16, 19,
  4011.             20, 21, 22, 23, 24, 25, 26,
  4012.             27, 28, 29, 30, 31, 32, 33,
  4013.             34, 35, 36, 37, 38, 39, 40,
  4014.             41, 42, 43, 44, 45, 46, 47,
  4015.             48, 49, 50, 51, 55, 56, 57,
  4016.             58, 60, 62
  4017.             priority, 4, 13, 19
  4018.             PS/2, 13, 16
  4019.             purge, 42, 43, 45, 56
  4020.  
  4021.             register, 5, 6, 7, 8, 12, 43,
  4022.             60
  4023.             Registration, 1, 2
  4024.             reset_modem, 55, 57
  4025.             RI, , 17, 44
  4026.  
  4027.             RTS, 7, 10, 20, 22, 30, 31,
  4028.             32, 33, 38
  4029.             Shareware, 1, 2, 16